Migration error

Run it to generate a new migration 1)rails generate migration add_price_to_product price:decimal

2)Added following to migration file

class AddPriceToProduct < ActiveRecord::Migration def self.up add_column :products, :price, :decimal, :precision => 8, :scale => 2, :default => 0 end def self.down remove_column :products, :price end end rake db:migrate                                               Then ran "rake db:migrate",it created a new columns in table products with name "price" ,but i didnt change the view(didnt create a filed with name "price")

Why

Thanks

amritpal p. wrote in post #995533: Run it to generate a new migration Then ran "rake db:migrate", it created a new columns in table products with name "price", but it didn't change the view (didn't create a field with name "price")

Why?

The clue's in the name - running rake db:migrate alters your database (hence 'db'). It is not responsible for changing the views.

Just to clarify that, you have to write code yourself to add the field to the view.

Colin

I followed the Agile web development with rails (3rd edition),which says it is possible.      By the way,thank you.

Ok. Thanks colin