Ruby on Rails Thursday, April 28, 2011

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


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment