I have 2 models Widget and Feature which have a has many through association using WidgetFeature model.
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
I have a widget_id.
So i do Widget.find_by_id(widget_id)
Now i want to find all the features for this widget where widget_features.children_features IS NULL
.
I dont know how to do this, help me out.