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