Ruby on Rails Naming Conventions Models

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The model is named using the class naming convention of unbroken MixedCase and is always the singular of the table name.

For Example: If a table was named orders, the associated model would be named Order

For Example: If a table was named posts, the associated model would be named Post

Rails will then look for the class definition in a file called order.rb in the /app/models directory.

If the model class name has multiple capitalized words, the table name is assumed to have underscores between these words.

For Example: If a model is named BlogPost then assumed table name will be blog_posts.



Got any Ruby on Rails Question?