Permalink
Browse files

Merge pull request #28092 from sikachu/fix-define_attribute_method-wi…

…th-symbol-in-ar

Fix `define_attribute_method` with Symbol in AR
  • Loading branch information...
guilleiguaran committed Feb 21, 2017
2 parents ba22c5e + 0b157f8 commit 5716c4ddf4e03c75bd50df901a515ac445167a99
@@ -289,7 +289,7 @@ def define_attribute_method(attr_name)
generate_method = "define_method_#{matcher.method_missing_target}"
if respond_to?(generate_method, true)
send(generate_method, attr_name)
send(generate_method, attr_name.to_s)
else
define_proxy_call true, generated_attribute_methods, method_name, matcher.method_missing_target, attr_name.to_s
end
@@ -866,6 +866,13 @@ def name
assert subklass.method_defined?(:id), "subklass is missing id method"
end
test "define_attribute_method works with both symbol and string" do
klass = Class.new(ActiveRecord::Base)
assert_nothing_raised { klass.define_attribute_method(:foo) }
assert_nothing_raised { klass.define_attribute_method("bar") }
end
test "read_attribute with nil should not asplode" do
assert_nil Topic.new.read_attribute(nil)
end

0 comments on commit 5716c4d

Please sign in to comment.