From 285cba022ce37977f977376a20ca866197ef33bd Mon Sep 17 00:00:00 2001 From: shotat Date: Wed, 14 Jun 2017 09:13:26 +0900 Subject: [PATCH] enhance active model assignment --- activemodel/lib/active_model/attribute_assignment.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/activemodel/lib/active_model/attribute_assignment.rb b/activemodel/lib/active_model/attribute_assignment.rb index 930e89d611..a0a6de8dd7 100644 --- a/activemodel/lib/active_model/attribute_assignment.rb +++ b/activemodel/lib/active_model/attribute_assignment.rb @@ -42,8 +42,9 @@ module ActiveModel end def _assign_attribute(k, v) - if respond_to?("#{k}=") - public_send("#{k}=", v) + setter = "#{k}=" + if respond_to?(setter) + public_send(setter, v) else raise UnknownAttributeError.new(self, k) end