Reputation: 85
I am new to rails.
I want to create an Article model. So I run,
rails g model Article name:string context:string
Instead of content I type in context, Is there a way to update the schema.rb file that gets generated?
I would like the articles table to have name and content columns.
Upvotes: 1
Views: 1660
Reputation: 18037
Don't focus on schema.rb -- this is just a dump of the current state of your database. Instead, what you need to do is correct the migration file. It is the migration files that actually define what tables/column will exist in production in the end so they must be correct. I'd recommend:
ls -ltr db/migrate
-- use this to find your migration file and copy the date string. Rails uses this as the "version" of the migration. For example: "20140809165359_create_articles", the version is "20140809165359".bundle exec rake db:migrate:down VERSION=20140809165359
(replace the version number with your own, here)bundle exec rake db:migrate
to migrate back up.This will fix the underlying problem and you'll notice that now, after migrating back up, your schema.rb will be fixed too.
Upvotes: 2