If I’d like to generate a controller for comments that belongs to a post which in turn belongs to a user, should I name this
rails g controller postsComments
Or
rails g controller postComments
Or
rails g controller postcomments
Or just
rails g controller comments
If you type,
you’ll get detailed instructions and an example of how to do it correctly. Basically, you can use either
CamelCaseorunder_scoredand the result will be the same.under_scoresin file names andCamelCasein class names.As for the name, I’d personally use
Comments, unless you plan to have another type of comments in your app and want to use a different class name for them.And finally the question whether you should use
PostsCommentsorPostCommentsis more about the english language than Rails. I think the more correct way would bePostComments, but I’m not a native speaker 🙂