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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’ve just generated it and realized your mistake you can use:
rails destroy scaffold myOdb2and then re-generate the scaffolding:
rails generate scaffold myOdb2 columna:integer, columnB:string, columnc:stringIf 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 myOdb2then create a migration to add the column:
rails generate migration add_columnc_to_myodb2s columnc:stringthen re-generate the controller and views:
rails generate scaffold_controller myOdb2 columna:integer, columnB:string, columnc:stringIf 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.