【发布时间】:2011-06-09 21:57:59
【问题描述】:
型号:
class Thread < ActiveRecord::Base
has_many :threaded, :through => :threaded, :foreign_key => :thread_id
class ThreadFeed < ActiveRecord::Base
belongs_to :threaded, :polymorphic => true
模型字段
Thread (id)
ThreadFeed (id, thread_id, threaded_id, threaded_type)
问题在于:
@thread.threaded
Rails 使用 (thread_id, threaded_type) 作为外键,我希望 thread_id 作为外键。
【问题讨论】:
-
嗯...通过关系进行多态可能会变得棘手。你能描述更多关于你正在尝试做的事情吗?
标签: ruby-on-rails ruby-on-rails-3 polymorphism polymorphic-associations