我有2个模型的小部件和功能,有一个有很多通过使用WidgetFeature模型的关联。与范围有很多通过协会
class Widget < ActiveRecord::Base
has_many :widget_features
has_many :features, :through => :widget_features
end
class WidgetFeature < ActiveRecord::Base
belongs_to :feature
belongs_to :widget
attr_accessible :children_features, :widget_id, :feature_id
end
class WidgetFeature < ActiveRecord::Base
belongs_to :feature
belongs_to :widget
attr_accessible :children_features, :widget_id, :feature_id
end
我有一个widget_id。
所以我做Widget.find_by_id(WIDGET_ID)
现在我想找到这个小工具,其中widget_features.children_features IS NULL
所有功能。
我不知道如何做到这一点,帮助我。
您粘贴WidgetFeature两次请提供功能模型 – Salil 2010-07-06 10:06:47