我有一个名为site
的模型。
site has_many site_settings
site_settings belongs_to setting
setting
有一个名为temporary
我希望site
和site_settings
之间的关系仅返回与临时site_settings
无关的setting
。
我试过了:
class Site < ActiveRecord::Base
has_many :site_settings, :dependent => :destroy,
:conditions => {:setting => {:temporary => false} }
我也尝试了Proc.new
的一些事情,但没有成功。
任何帮助?
答案 0 :(得分:1)
不要忘记加入/包含设置:
has_many :site_settings, :dependent => :destroy, :include => :setting, :conditions => {:setting => {:temporary => false}}