Best way to add attributes to User Model in Ruby on Rails

ruby-on-rails

Solution

The proper way is to create a new migration. In the main rails project folder, run

`rails generate migration AddDetailsToUser address:string age:integer` etc...

and then run `rake db:migrate`

An alternative to this is to edit the original migration file, reset/destroy the database and re-run all migrations.

Problem

my User Model looks like: ``` class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name t.string :email t.timestamps end end def self.down drop_table :users end end ``` If I wanted add one more :attribute, is it best to create another migration file for adding a new column (see another Stackoverflow thread) or can I just manually add t.string :name_of_new_attribute and then rake db:migrate? Thanks!

Original source

Related problems