Skip to content

Commit

Permalink
Merge pull request #1 from front/rails6.1-compatibility
Browse files Browse the repository at this point in the history
Rails 6.1 compatibility
  • Loading branch information
SofiaSousa authored Mar 14, 2022
2 parents 0c22ba2 + 8cd3839 commit 9a14008
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/dynamic_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ def update_attributes(attributes)
set_dynamic_attributes(attributes)
super(attributes)
end

# Overrides update to take dynamic attributes into account
# (Rails 6.1 ActiveRecord deprecates update_attributes methods)
def update(attributes)
set_dynamic_attributes(attributes)
super(attributes)
end

# Creates an accessor when a non-existing setter with the configured dynamic attribute prefix is detected. Calls super otherwise.
def method_missing(method, *arguments, &block)
Expand Down Expand Up @@ -120,7 +127,7 @@ def set_dynamic_attribute(att, value = nil)
update_dynamic_attribute(att, value)
end

# Called on object initialization or when calling update_attributes to convert passed dynamic attributes
# Called on object initialization or when calling update_attributes/update to convert passed dynamic attributes
# into attributes that will be persisted by calling set_dynamic_attribute if it does not exist already.
# The serialization column will also be updated and the detected dynamic attributes are removed from the passed
# attributes hash.
Expand Down

0 comments on commit 9a14008

Please sign in to comment.