From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Model naming

Model naming - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Model naming

- [Instructor] In this movie, we will take a closer look at the models we generated in the last chapter. There are some important details we need to understand. To review, when you want to generate a model, you go to the command line at the root of your Rails application, and you type rails generate model, and then the singular name of the model that you want, in Camel case. For example, rails generate model Subject, and that does a number of things for you. It creates a migration file for you, in DB/migrate, and it gives it a filename, which is automatically named create underscore subjects. Notice that it is plural. That file has a class name inside of CreateSubjects. Also notice that that's plural. Then, the table that we're going to be creating is also going to be called subjects. The generator will also create a file in your models directory, and that one will be called subject dot RB, singular. If we look inside it, we'll see that it defines a class name, which is Subject, and…

Contents