这种关联在 Rails 3 中运行良好,因此对于用户,我可以获得由 Quest.status 订购的 UserQuest。我在 Rails 4 中找不到如何获得它。感谢您的帮助。
class Quest < ActiveRecord::Base
has_many :user_quests
end
class UserQuest < ActiveRecord::Base
belongs_to :user
belongs_to :quest
end
class User < ActiveRecord::Base
has_many :user_quests, :include => :quest, :order => "Quest.status DESC", :dependent => :delete_all
end