HowTo add and remove attributes from models in Rails 2.0
Posted on 19th November 2008 by Guillaume Moigneu
0
Rails 2.0 has introduced a new and easy way to alter the attributes of a model.
To add an attribute “author” to a model “post” :
script/generate migration AddAuthorToPost author:string
To delete this attribute :
script/generate migration RemoveAuthorFromPost author:string
Add and Remove specify the action to do and Post, separated by To or From, is the name of the model.
Don’t forget to run the migration by using :
rake db:migrate
Popularity: 78% [?]











