mirror of https://github.com/rails/rails
Merge pull request #49836 from skipkayhil/hm-assign-attribute-respond-to
Remove respond_to? in assign_attribute happy path
This commit is contained in:
commit
ed2839dd9e
|
@ -45,8 +45,10 @@ module ActiveModel
|
|||
|
||||
def _assign_attribute(k, v)
|
||||
setter = :"#{k}="
|
||||
public_send(setter, v)
|
||||
rescue NoMethodError
|
||||
if respond_to?(setter)
|
||||
public_send(setter, v)
|
||||
raise
|
||||
else
|
||||
raise UnknownAttributeError.new(self, k.to_s)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue