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.

On 28 April 2011 15:47, Pale H. [email protected] wrote:

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

On Apr 28, 10:47am, Pale H. [email protected] wrote:

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.
I followed the Agile web development with rails (3rd
edition),which says it is possible.
By the way,thank you.

On Apr 28, 12:49pm, Colin L. [email protected] wrote:

(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.
Ok.
Thanks colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs