0

我有一个模型叫site.

site has_many site_settings
site_settings belongs_to setting
setting有一个名为的布尔字段temporary

我希望和之间的关系sitesite_settings返回site_settings与临时无关的setting.

我试过了:

class Site < ActiveRecord::Base

  has_many :site_settings, :dependent => :destroy, 
    :conditions => {:setting => {:temporary => false} }

我也尝试过一些事情Proc.new,但没有成功。

有什么帮助吗?

4

1 回答 1

1

不要忘记加入/包括设置:

has_many :site_settings, :dependent => :destroy, :include => :setting, :conditions => {:setting => {:temporary => false}}
于 2012-12-27T02:24:40.263 回答