Created
November 28, 2014 20:07
-
-
Save meierjan/0758f1eaa2f736693f7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Feature < ActiveRecord::Base | |
has_many :flat_features | |
has_many :flats, through: :flat_features | |
end | |
class FlatFeature < ActiveRecord::Base | |
belongs_to :flat | |
belongs_to :feature | |
end | |
class Flat < ActiveRecord::Base | |
has_many :flat_features | |
has_many :features, through: :flat_features | |
def full_feature_list() | |
Feature.all.map { |feature| [feature, self.features.include? feature ] } | |
end | |
def has_feature(feature) | |
self.features.include? feature | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment