Am having trouble with rake file, but can''t find problem. Can you help? Haven''t been able to understand the error message returned. Thank you. --------------------------------------------------------------------------------- Macintosh:depot pdenlinger$ rake db:migrate (in /Users/pdenlinger/Sites/depot) rake aborted! ./db/migrate//20091112074628_add_price_to_product.rb:4: syntax error, unexpected tASSOC, expecting kEND :precision => 8, :scale => 2, :default => 0 ^ (See full trace by running task with --trace) Macintosh:depot pdenlinger$ rake db:migrate (in /Users/pdenlinger/Sites/depot) rake aborted! ./db/migrate//20091112074628_add_price_to_product.rb:4: syntax error, unexpected tASSOC, expecting kEND :precision =>8, :scale =>2, :default =>0 ^ (See full trace by running task with --trace) Macintosh:depot pdenlinger$ rake db:migrate (in /Users/pdenlinger/Sites/depot) rake aborted! ./db/migrate//20091112074628_add_price_to_product.rb:4: syntax error, unexpected tASSOC, expecting kEND :precision => 8, :scale => 2, :default => 0 ^ (See full trace by running task with --trace) Macintosh:depot pdenlinger$ rake db:migrate (in /Users/pdenlinger/Sites/depot) rake aborted! ./db/migrate//20091112074628_add_price_to_product.rb:4: syntax error, unexpected tASSOC, expecting kEND :precision => 8, :scale => 2, :default => 0 ^ (See full trace by running task with --trace) Macintosh:depot pdenlinger$ rake db:migrate --trace (in /Users/pdenlinger/Sites/depot) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! ./db/migrate//20091112074628_add_price_to_product.rb:4: syntax error, unexpected tASSOC, expecting kEND :precision => 8, :scale => 2, :default => 0 ^ /Users/pdenlinger/.gem/ruby/1.8/gems/activesupport-2.3.4/lib/ active_support/dependencies.rb:145:in `load_without_new_constant_marking'' /Users/pdenlinger/.gem/ruby/1.8/gems/activesupport-2.3.4/lib/ active_support/dependencies.rb:145:in `load'' /Users/pdenlinger/.gem/ruby/1.8/gems/activesupport-2.3.4/lib/ active_support/dependencies.rb:521:in `new_constants_in'' /Users/pdenlinger/.gem/ruby/1.8/gems/activesupport-2.3.4/lib/ active_support/dependencies.rb:145:in `load'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:373:in `load_migration'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:369:in `migration'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:365:in `migrate'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:486:in `migrate'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:560:in `call'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:560:in `ddl_transaction'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/connection_adapters/abstract/database_statements.rb: 136:in `transaction'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/transactions.rb:182:in `transaction'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:560:in `ddl_transaction'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:485:in `migrate'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:472:in `each'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:472:in `migrate'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:400:in `up'' /Users/pdenlinger/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:383:in `migrate'' /Library/Ruby/Gems/1.8/gems/rails-2.3.4/lib/tasks/databases.rake:116 /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_chain'' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ 1.8/monitor.rb:242:in `synchronize'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_task'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_level'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/bin/rake:31 /usr/bin/rake:19:in `load'' /usr/bin/rake:19 Macintosh:depot pdenlinger$ rake db:migrate
Can I see what''s in 20091112074628_add_price_to_product.rb ? It says there''s a syntax error in your migration. On Thu, Nov 12, 2009 at 9:12 AM, pauld <paul.denlinger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Am having trouble with rake file, but can''t find problem. Can you > help? Haven''t been able to understand the error message returned. > > Thank you. > > --------------------------------------------------------------------------------- > > Macintosh:depot pdenlinger$ rake db:migrate > (in /Users/pdenlinger/Sites/depot) > rake aborted! > ./db/migrate//20091112074628_add_price_to_product.rb:4: syntax error, > unexpected tASSOC, expecting kEND > :precision => 8, :scale => 2, :default => 0
Here you go: 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 On Nov 12, 4:16 pm, Franz Strebel <franz.stre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Can I see what''s in 20091112074628_add_price_to_product.rb ? > It says there''s a syntax error in your migration. > > > > On Thu, Nov 12, 2009 at 9:12 AM, pauld <paul.denlin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Am having trouble with rake file, but can''t find problem. Can you > > help? Haven''t been able to understand the error message returned. > > > Thank you. > > > --------------------------------------------------------------------------- ------ > > > Macintosh:depot pdenlinger$ rake db:migrate > > (in /Users/pdenlinger/Sites/depot) > > rake aborted! > > ./db/migrate//20091112074628_add_price_to_product.rb:4: syntax error, > > unexpected tASSOC, expecting kEND > > :precision => 8, :scale => 2, :default => 0
On Thu, Nov 12, 2009 at 2:06 AM, pauld <paul.denlinger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Here you go: > > class AddPriceToProduct < ActiveRecord::Migration > def self.up > add_column :products, :price, :decimal > :precision => 8, :scale => 2, :default => 0 >It seems that you have missed a comma after the field type (i.e. decimal) and it should be implemented as follows: add_column :products, :price, :decimal, :precision => 8, :scale => 2, :default => 0 Thus, the migration should look as follows: 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 Good luck, -Conrad> end >def self.down> remove_column :products, :price > end > end > > On Nov 12, 4:16 pm, Franz Strebel <franz.stre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Can I see what''s in 20091112074628_add_price_to_product.rb ? > > It says there''s a syntax error in your migration. > > > > > > > > On Thu, Nov 12, 2009 at 9:12 AM, pauld <paul.denlin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Am having trouble with rake file, but can''t find problem. Can you > > > help? Haven''t been able to understand the error message returned. > > > > > Thank you. > > > > > > --------------------------------------------------------------------------- > ------ > > > > > Macintosh:depot pdenlinger$ rake db:migrate > > > (in /Users/pdenlinger/Sites/depot) > > > rake aborted! > > > ./db/migrate//20091112074628_add_price_to_product.rb:4: syntax error, > > > unexpected tASSOC, expecting kEND > > > :precision => 8, :scale => 2, :default => 0 > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The missing comma was the problem. The migration worked now. Thank you. pauld On Nov 12, 6:39 pm, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Nov 12, 2009 at 2:06 AM, pauld <paul.denlin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Here you go: > > > class AddPriceToProduct < ActiveRecord::Migration > > def self.up > > add_column :products, :price, :decimal > > :precision => 8, :scale => 2, :default => 0 > > It seems that you have missed a comma after the field type (i.e. decimal) > and it should be > implemented as follows: > > add_column :products, :price, :decimal, :precision => 8, :scale => 2, > :default => 0 > > Thus, the migration should look as follows: > > 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 > > Good luck, > > -Conrad > > > end > > def self.down > > > remove_column :products, :price > > end > > end > > > On Nov 12, 4:16 pm, Franz Strebel <franz.stre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Can I see what''s in 20091112074628_add_price_to_product.rb ? > > > It says there''s a syntax error in your migration. > > > > On Thu, Nov 12, 2009 at 9:12 AM, pauld <paul.denlin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Am having trouble with rake file, but can''t find problem. Can you > > > > help? Haven''t been able to understand the error message returned. > > > > > Thank you. > > > --------------------------------------------------------------------------- > > ------ > > > > > Macintosh:depot pdenlinger$ rake db:migrate > > > > (in /Users/pdenlinger/Sites/depot) > > > > rake aborted! > > > > ./db/migrate//20091112074628_add_price_to_product.rb:4: syntax error, > > > > unexpected tASSOC, expecting kEND > > > > :precision => 8, :scale => 2, :default => 0