Created
October 24, 2016 14:28
-
-
Save universal/68dcefd5ab0bb12f0ce9321db97503d8 to your computer and use it in GitHub Desktop.
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
class AdditionalDomain < AR::Base | |
belongs_to :report | |
belongs_to :domain | |
validates :report, presence: true | |
validates :domain, presence: true | |
end |
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
class Domain < AR::Base | |
end |
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
class Report < AR::Base | |
belongs_to :primary_domain, class_name: "Domain" | |
has_many :additional_domains | |
has_many :domains, through: :additional_domains | |
validates :primary_domain, presence: true # checks object is on the association, but also allows new records | |
validates :primary_domain_id, presence: true # checks numeric value is set, but this could be a non existing value | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment