Trouble with rake

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:inload’
/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:inload’
/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:inmigration’
/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:inmigrate’
/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:inddl_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:intransaction’
/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:inmigrate’
/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:inmigrate’
/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:inmigrate’
/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:inexecute’
/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:inexecute’
/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:insynchronize’
/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:ininvoke’
/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:intop_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:intop_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:intop_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:instandard_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:inload’
/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.

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

The missing comma was the problem. The migration worked now.

Thank you.

pauld

On Thu, Nov 12, 2009 at 2:06 AM, pauld [email protected] 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