As a principle of Rails, there is ** "Convention over configuration" **. There are conventions for naming conventions (that is, naming conventions) for class names and filenames for models, controllers, and views.
The names related to the controller and view when the controller name is "comments" are as follows.
name | Example | rule |
---|---|---|
Controller class name | CommentsController | 〇〇Controller, capital letters at the beginning |
Controller file name | comments_controller.rb | 〇〇_controller.rb |
Template directory name | app/views/commnents | app/views/〇〇 |
The name when the model name is "comment" is as follows.
name | Example | rule |
---|---|---|
Database table name | comments | Start with lowercase letters, plural |
Model class name | Comment | Uppercase at the beginning |
Model class filename | comment.rb | 〇〇.rb |
" shopping_carts "
. in this case,--Controller class name: ShoppingCartsController --Model class name: ShoppingCart
Recommended Posts