How does one add an attribute to a model?

jsttn picture jsttn · Jun 16, 2011 · Viewed 48.7k times · Source

In rails I generate a model with two strings and would like to add more. How would I go about doing this?

Answer

vishB picture vishB · Jun 1, 2012

Yes, the solution by @JCorcuera is applicable, but I suggest applying a little more information to Rails to fulfill our requirement. Try this approach:

rails generate migration add_columnname_to_tablename columnname:datatype

For example:

rails generate migration add_password_to_users password:string