Skip to content

Commit

Permalink
Look up invited_by_class_name on the current model rather than the gl…
Browse files Browse the repository at this point in the history
…obal config, this allows multiple invitable models with different configs.
  • Loading branch information
bradleypriest authored and scambra committed Oct 16, 2024
1 parent 12b5f08 commit 5bfcc77
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/devise_invitable/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ module Invitable

included do
include ::DeviseInvitable::Inviter
belongs_to_options = if Devise.invited_by_class_name
{ class_name: Devise.invited_by_class_name }
belongs_to_options = if invited_by_class_name
{ class_name: invited_by_class_name }
else
{ polymorphic: true }
end
Expand Down Expand Up @@ -78,7 +78,7 @@ def self.required_fields(klass)
fields = [:invitation_token, :invitation_created_at, :invitation_sent_at, :invitation_accepted_at,
:invitation_limit, Devise.invited_by_foreign_key || :invited_by_id, :invited_by_type]
fields << :invitations_count if defined?(ActiveRecord) && self < ActiveRecord::Base
fields -= [:invited_by_type] if Devise.invited_by_class_name
fields -= [:invited_by_type] if invited_by_class_name
fields
end

Expand Down

0 comments on commit 5bfcc77

Please sign in to comment.