Skip to content

Commit

Permalink
fix(actable): safeguard scope to be options
Browse files Browse the repository at this point in the history
  • Loading branch information
bivanalhar committed Jul 23, 2024
1 parent 6b1de5b commit 41b0796
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/active_record/acts_as/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Relation
extend ActiveSupport::Concern

module ClassMethods
def acts_as(name, scope = nil, options = {})
def acts_as(name, scope = nil, **options)
options, scope = scope, nil if Hash === scope

association_method = options.delete(:association_method)
Expand Down Expand Up @@ -84,6 +84,8 @@ def is_a?(klass)
end

def actable(scope = nil, **options)
options, scope = scope, nil if Hash === scope

name = options.delete(:as) || :actable

reflections = belongs_to(name, scope, **options.reverse_merge(validate: false,
Expand Down

0 comments on commit 41b0796

Please sign in to comment.