与这种关联作斗争,我有两个模型:人偶和市场,市场是您可以与其他人交易您的玩具人偶的地方。
Figure class
figure_id:integer
name :string
image_url:string
Market class
market_id:integer
figure_you_want_to_trade_id :integer #this should be associated with the figure_id
figure_you_want_from_someone_else_id:integer #this should be associated with the figure_id
我该如何建立这个协会?
我在想:
market.rb
has_many :figure_to_trade, :class_name => Figure, :foreign_key => figure_id
has_many :figure_you_want, :class_name => Figure, :foreign_key => figure_id
figure.rb
belongs_to :figure_you_want_to_trade, :class_name => Market
belongs_to :figure_you_want_from_someone_else, :class_name => Market
这是我在尝试输出时收到的错误:<%= market.figure_to_trade %>
SQLite3::SQLException:没有这样的列:figures.figure_id: SELECT "figures".* FROM "figures" WHERE "figures"."figure_id" = 1