Created
May 4, 2020 07:47
-
-
Save dmitryzuev/00aa6663f5db84345cf7a1de091fd29c 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 Customer < ApplicationRecord | |
has_many :customer_documents | |
has_many :documents, through: :customer_documents | |
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 CustomerDocument < ApplicationRecord | |
belongs_to :customer | |
belongs_to :document | |
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 Document < ApplicationRecord | |
belongs_to :document_type | |
has_many :customer_documents | |
has_many :customers, through: :customer_documents | |
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 DocumentType < ApplicationRecord | |
has_many :documents | |
has_many :customers, -> { distinct }, through: :documents | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment