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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> 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. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 28 April 2011 15:47, Pale Horse <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
amritpal p. wrote in post #995532:> 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")Migrations don''t do that (you can create migrations to do all sorts of things, not necessarily related to new fields for a view). -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 28, 10:47 am, Pale Horse <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On Apr 28, 12:49 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 28 April 2011 15:47, Pale Horse <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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.Ok. Thanks colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.