Reputation: 52530
What is the naming convention for models in Rails? If my model is about flying cars, which of the following class names is most appropriate?
class FlyingCar < ActiveRecord::Base
attr_accessible :model, :max_speed
end
class Flying_Car < ActiveRecord::Base
attr_accessible :model, :max_speed
end
class Flying_car < ActiveRecord::Base
attr_accessible :model, :max_speed
end
Upvotes: 2
Views: 350
Reputation: 13972
Your model class name must be PascalCase (FlyingCar) and it must be singular.
For controller classes it's PascalCase, plural, and ends with Controller (so: FlyingCarsController)
Upvotes: 1
Reputation: 5779
FlyingCar is the Ruby convention. This becomes even more important when ActiveRecord is trying to do its magic. There's ways you can override this behavior, but using FlyingCar is what ActiveRecord expects.
Upvotes: 5