aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-01-15 12:06:50 +0100
committerPiotr Sarnacki <drogus@gmail.com>2012-01-15 16:01:05 +0100
commitdee595ce04b65d27294912faff146ed402ded6d1 (patch)
tree4808974cd8dcc5c19d13e4618116a6cbad32fc53 /activemodel/lib/active_model
parent95027d224050a3715677a09593d5891bd71a732e (diff)
downloadrails-dee595ce04b65d27294912faff146ed402ded6d1.tar.gz
rails-dee595ce04b65d27294912faff146ed402ded6d1.tar.bz2
rails-dee595ce04b65d27294912faff146ed402ded6d1.zip
Fix stack level too deep when model does not have attributes method.
Without that patch when using ActiveModel::AttributeMethods in a class that does not respond to `attributes` method, stack level too deep error will be raised on non existing method. While documentation is clear that you need to define `attributes` method in order to use AttributeMethods module, `stack level too deep` is rather obscure and hard to debug, therefore we should try to not break `method_missing` if someone forgets about defining `attributes`.
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb
index dba059eacd..91c6b9721c 100644
--- a/activemodel/lib/active_model/attribute_methods.rb
+++ b/activemodel/lib/active_model/attribute_methods.rb
@@ -434,7 +434,7 @@ module ActiveModel
protected
def attribute_method?(attr_name)
- attributes.include?(attr_name)
+ respond_to_without_attributes?(:attributes) && attributes.include?(attr_name)
end
private