我有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