Search code examples
ruby-on-railsrubymodelrails-console

Ruby on Rails: How to add parameter to database in existing model


I built a model using rails g model name:string, description:text, price:float, and finished my project, but now want to add more parameters to the model. Instead of starting over, how can I add more parameters? Is there a method to do so within the rails console?


Solution

  • rails generate migration AddColumnToTable column:datatype
    

    so if you wanted to add a name column to a people table it might look like:

    rails generate migration AddNameToPeople name:string
    

    then run rake db:migrate