[RUBY] Naming convention when creating a new controller or model with rails

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.

The most important point

・ Creating a new controller is ** plural ** ・ Creating a new model is ** singular ** ・ Both controller and model ** Snake case and camel case can be used **

controller

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

model

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

Naming convention when creating a new controller or model with rails
[Rails] Creating a new project with rails new
[Rails] Avoid SELECT issued when creating a model with belongs_to defined!
Creating a new user with rails was angry with unknown attribute'password' for User.
[Rails6] Create a new app with Rails [Beginner]
Rails Basics of creating a new application
[Rails 5] Create a new app with Rails [Beginner]
[Rails] Naming convention
[Rails] rails new to create a database with PostgreSQL
[For beginners] Procedure for creating a controller using rails
A memorandum when creating a REST service with Spring Boot
How to get started with creating a Rails app
[Review] When creating a web application with Rails, syntax error, unexpected')', expecting => ...]}% ","% # {params [: content]}% "]) ...
Rough procedure verbalized output when creating an app with Rails
Summary of initial work when creating an app with Rails
How to specify db when creating an app with rails
Existing records disappear when building a model of has_one (rails)
[Rails] Launch a new project
About naming Rails model methods
I got a warning message with the rails _6.0.3_ new hello_myapp command
How to rename a model with foreign key constraints in Rails
Creating a timer app with a muddy
Thinking when introducing a new library
Rails model and table naming conventions
Precautions when creating PostgreSQL with docker-compose
When you want Rails to disable a session for a specific controller only
Settings that should be done when operating a production environment with Rails
A collection of methods often used when manipulating time with TimeWithZone of Rails
A memorandum when starting new development with IntelliJ + Gradle + SpringBoot + JUnit5 (jupiter)