New
$ rails g controller
$ rails g model
When you do
** "Oh, when it's a controller, do you make it plural?" ** ** "How should I write when specifying multiple words in the model name?" **
I was googled every time, so it also serves as a memory retention.
・ Creating a new controller is ** plural ** ・ Creating a new model is ** singular ** ・ Both controller and model ** Snake case and camel case can be used **
When creating a new controller, be sure to specify it in the plural form.
$ rails g controller users
$ rails g controller posts
$ rails g controller likes
When combining multiple words, either snake case or camel case is OK.
$ rails g controller post_likes #Snake case
$ rails g controller PostLikes #Camel case
When creating a new model, specify it in the singular.
$ rails g model user
$ rails g model post
$ rails g model like
When combining multiple words, either snake case or camel case is OK.
$ rails g model post_like
$ rails g model PostLike
I will explain it a little more carefully when I have time. For reference only.
Recommended Posts