Great! You created a new Rails app named MessengerApp.

Looking at this diagram of the request/response cycle, we need four parts to build a Rails app - a model, a route, a controller, and a view.

Let’s start here by creating a model.



In the terminal, generate a new model named Message

rails generate model Message

Open the migration file in db/migrate/ for the messages table. The name of the migration file starts with the timestamp of when it was created. Inside the change method, add this line as line 4:

t.text :content

Then in the terminal, run

bundle exec rake db:migrate

Finally, run

bundle exec rake db:seed

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?