开发者

Naming convention Rails

开发者 https://www.devze.com 2023-03-08 03:18 出处:网络
I read that Rails开发者_如何学JAVA follows some naming conventions, model name should be singular and controller name should be plural.

I read that Rails开发者_如何学JAVA follows some naming conventions, model name should be singular and controller name should be plural.

I have a model called body and i would like to know how am i supposed to name my controller's name -- should it be 'bodies' or 'bodys'??

Thanks for for any suggestion provided ;)

Sorry for this newbie question


to be precise your model should be called 'Body' (more of a Ruby thing to capitalize class names). ActiveRecord will automagically look in the SQL table called 'bodies' for any database interaction (create, update, delete).

Your controller will be called BodiesController in a file app/controllers/bodies_controller.rb.


following conventions bodies

class BodiesController
end


It should be bodies_controller. Bodys - something from children wear stuff =)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号