Skip to content

Commit

Permalink
Use the "polymorphic_name" method to explicitly tell ActiveRecord wha…
Browse files Browse the repository at this point in the history
…t model name to use in the has_many :through join
  • Loading branch information
RSpace committed Jan 27, 2020
1 parent 7f17003 commit 648de2c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/organization.rb
Expand Up @@ -2,5 +2,9 @@ class Organization < ApplicationRecord
self.table_name = 'organisations'

has_many :roles, as: :access_to
has_many :users, through: :roles, source: :access_to, source_type: "Organisation"
has_many :users, through: :roles

def self.polymorphic_name
"Organisation"
end
end

0 comments on commit 648de2c

Please sign in to comment.