Adding a new field to Rails model
ruby-on-rails
Solution
If you've just generated it and realized your mistake you can use:
`rails destroy scaffold myOdb2`
and then re-generate the scaffolding:
`rails generate scaffold myOdb2 columna:integer, columnB:string, columnc:string`
If you've made some changes to the scaffold-created model that you want to keep but you don't mind destroying the controller and views:
`rails destroy scaffold_controller myOdb2`
then create a migration to add the column:
`rails generate migration add_columnc_to_myodb2s columnc:string`
then re-generate the controller and views:
`rails generate scaffold_controller myOdb2 columna:integer, columnB:string, columnc:string`
If you've made changes to the controller or views, you'll need to just run the migration to update the database and model, then manually add the new column to each of your views.
Problem
I already created a scafold using ``` rails generate scaffold myOdb2 columna:integer, columnB:string ``` now I want to add `columnc:string`. What should I do? BTW: question is general but can it be done quicker through Rubymine?