Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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