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 - Ruby on Rails Tutorial
From the course: Ruby on Rails 5 Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
ActiveRecord and ActiveRelation4m 32s
-
(Locked)
Model naming5m 52s
-
(Locked)
Model attributes2m 51s
-
(Locked)
The Rails console3m 17s
-
(Locked)
Create records4m 53s
-
(Locked)
Update records3m 16s
-
(Locked)
Delete records2m 29s
-
(Locked)
Find records5m 48s
-
(Locked)
Query methods: Conditions7m 39s
-
(Locked)
Query methods: Order, limit, and offset6m 29s
-
(Locked)
Named scopes8m 26s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-