Let's say I forgot to add a field to my model. How do I go about adding it cleanly? Do I need to re-run rails generate or can I edit a file somewhere?
Either you should re-run your generate scaffold/model (will blow away existing code)
or you can add the field directly to the database and your view
Rails3:
rails generate migration add_column_name_to_table_name column_name:string
or
Rails2.x:
ruby script/generate migration addColumnToTableName column_name:string
which will generate a file in db/migrate which you can apply with a 'rake db:migrate'
Then you should modify your views to add the appropriate code to display/edit the new field.
more info: http://railscasts.com/episodes/83-migrations-in-rails-2-0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With