I have a person table with name and email as the columns,
Will the following line create a column "address" in the table:
person = Person.create(:name => "August", :email => "[email protected]", :address => "Maker Street")
I have a person table with name and email as the columns,
Will the following line create a column "address" in the table:
person = Person.create(:name => "August", :email => "[email protected]", :address => "Maker Street")
Do following steps -
step 1 : First Create new column Address in Person table, by following command -
rails g migration add_address_to_person address:string
step 2 : Migrate database
rake db:migrate
step 3 : Create Person with Address column -
person = Person.create(:name => "August", :email => "[email protected]", :address => "Maker Street")
Above method will insert values in Person table's Name, Email and Address column.
Add a new column
address
to thePerson
table:Migrate the database:
Create the record:
Note: You could also use
rails g migration AddAddressToPerson address
sincestring
is the default datatype.