Last active
August 29, 2015 14:18
-
-
Save jeffreyjurgajtis/f8587c852d2a229f4763 to your computer and use it in GitHub Desktop.
FeatureModeling
This file contains hidden or 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
# models/feature.rb | |
class Feature | |
validates :name, presence: true, uniqueness: true | |
end | |
# models/feature_provider.rb | |
class FeatureProvider | |
belongs_to :feature | |
belongs_to :provider, polymorphic: true | |
validates_presence_of :feature, :provider | |
end | |
# models/apartment.rb | |
class Apartment | |
has_many :feature_providers, as: :provider, dependend: :destroy | |
has_many :features, through: :feature_providers | |
end | |
# models/neightborhood.rb | |
class Apartment | |
has_many :feature_providers, as: :provider, dependend: :destroy | |
has_many :features, through: :feature_providers | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment