我正在尝试使用遇到错误的rails构建音乐应用程序,只是想知道有人知道这意味着什么吗?
当我这样做
rails g migration add_quantity_to_line_items quantity:integer, default: 1
rails db:migrate
后退
rails aborted!
SyntaxError: /Users/Code/Ruby/musicapp/db/migrate/20190605091214_add_quantity_to_line_items.rb:4: syntax error, unexpected tSYMBEG, expecting do or '{' or '('
add_column :line_items, :default, :string
^
/Users/mrswordsmith/Code/Ruby/musicapp/db/migrate/20190605091214_add_quantity_to_line_items.rb:5: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
add_column :line_items, :1, :string
class AddQuantityToLineItems < ActiveRecord::Migration[5.2]
def change
add_column :line_items, :quantity, :integer,
add_column :line_items, :default, :string
add_column :line_items, :1, :string
end
end
答案 0 :(得分:3)
如果我正确理解您想要实现的目标是:
class AddQuantityToLineItems < ActiveRecord::Migration[5.2]
def change
add_column :line_items, :quantity, :integer, default: 1
end
end
您的迁移脚本中有2个错误:
,
)因此,迁移脚本仅应为rails g migration add_quantity_to_line_items quantity:integer