alex@alex-ThinkPad-T410:~/rails_projects/final$ rake db:migrate
rake aborted!
/home/alex/rails_projects/final/db/migrate/20120813025503_add_price_location_and_product_to_microposts.rb:3: syntax error, unexpected ':', expecting ';' or '\n'
add_column :microposts, :price, :text # d...
^
/home/alex/rails_projects/final/db/migrate/20120813025503_add_price_location_and_product_to_microposts.rb:3: syntax error, unexpected ',', expecting tCOLON2 or '[' or '.'
...add_column :microposts, :price, :text # dont forget to chang...
... ^
/home/alex/rails_projects/final/db/migrate/20120813025503_add_price_location_and_product_to_microposts.rb:7: syntax error, unexpected keyword_end, expecting $end
这是错误。这是迁移(下面)
class AddPriceLocationAndProductToMicroposts < ActiveRecord::Migration
def
add_column :microposts, :price, :text
add_column :microposts, :location, :text
add_column :microposts, :product, :text
end
end
我写下了这个http://guides.rubyonrails.org/migrations.html#changing-migrations部分。 2.2
为什么要分号?我正在尝试将价格,位置,产品列添加到微博表
答案 0 :(得分:2)
您必须在def
即。将def
更改为def change
class AddPriceLocationAndProductToMicroposts < ActiveRecord::Migration
def change
add_column :microposts, :price, :text
add_column :microposts, :location, :text
add_column :microposts, :product, :text
end
end