From the course: Ruby on Rails 6 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Migrations for the CMS - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training
Solution: Migrations for the CMS
(upbeat music) - [Instructor] In this movie, I'll show you the solution that I came up with to the Migration challenge. The first thing I did was I came to the command line, and I made sure I was inside the root of my rails project. Then I ran rails generate, and I had to choose, do I want to generate a migration or a model. Since I'm creating a new model, a brand new table with a model attached to it, I wanted to choose model, and that model's going to be the subject model, and I went ahead and provided the names of the columns and the types of columns here as a list. Again, this is an optional step. You don't have to do it, but it's a nice shorthand. So I'm going to create a name column, position, and visible. If we jump over to the code, you can see that it created that file, create subjects, and it has create table, subjects, lower case and plural, and you can see that it has name, position and visible as a string…
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)
Create a database for a Ruby on Rails project2m 17s
-
(Locked)
Write migrations to define database changes3m 16s
-
(Locked)
Use the command line to generate migrations7m 6s
-
(Locked)
Run migrations to change the database schema6m 2s
-
(Locked)
Challenge: Migrations for the CMS3m 50s
-
(Locked)
Solution: Migrations for the CMS2m 50s
-
(Locked)
-
-
-
-