Naming is one of the hard things in computer science and I TOTALLY AGREE. Not only make a good, descriptive, and a cool name is hard, but the wrong name brings you bad luck.
This is one of my rails stories. I have an entity (table/model/active record/whatever you called it) named as Suspension
. Since the name not longer good makes sense for our scope, so I renamed it to Action
and this is what happened.
undefined method `permit' for "create":String
The action is already used as a field on rails generated form, so I need to think of another name.
{
"utf8"=>"✓",
"authenticity_token"=>"some token",
"query"=>{"name"=>"asdf"},
"controller"=>"queries",
"action"=>"create"
}
Then I renamed it to Callback
. Guess what happened? Yes, Rails already have a class named Callback. Huh.. I do miss java with all its exports in deep of my heart.
undefined method `new' for ActiveSupport::Callbacks::Callback:Class
It’s not so easy to fix this since you must manually rename the model, controller, view, spec, and everything. Actually, there is some tool called RailsRefactor, but I don’t know how it works and feel insecure if something changes my code without my knowing.
Check the rails reserved word list before you decide on some name.
Previously published in https://imantung.github.io at 25 Aug 2017