How to add field to a table in ruby on rails or alter table

    To add new field to a table open terminal window go to rails app directory
    $ rails generate migration <fieldname>_to_<tablename> <fieldname>:<datatype>

    $ rake db:migrate //You are done


    Where,
               <fieldname> name of field
                <tablename> name of table to add field
                <datatype> datatype of field (string, text, integer, float etc)
    5
    Average: 5 (1 vote)