diff options
author | Ian Ker-Seymer <i.kerseymer@gmail.com> | 2015-02-23 18:45:46 -0700 |
---|---|---|
committer | Ian Ker-Seymer <i.kerseymer@gmail.com> | 2015-02-24 11:00:32 -0700 |
commit | c5d62cb86d958aaa68a4057b3c2578329044e674 (patch) | |
tree | be03541b30100c8b38651decb1813fcd43d8f4b1 /activemodel/lib/active_model | |
parent | f6a31f532167eaffe0709af50c2d2190f2f76219 (diff) | |
download | rails-c5d62cb86d958aaa68a4057b3c2578329044e674.tar.gz rails-c5d62cb86d958aaa68a4057b3c2578329044e674.tar.bz2 rails-c5d62cb86d958aaa68a4057b3c2578329044e674.zip |
activemodel: make .model_name json encodable
Previously, calling `User.model_name.to_json` would result in an infinite
recursion as `.model_name` inherited its `.as_json` behavior from Object. This
patch fixes that unexpected behavior by delegating `.as_json` to :name.
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index 2bc3eeaa19..22010b517c 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -130,7 +130,7 @@ module ActiveModel # # Equivalent to +to_s+. delegate :==, :===, :<=>, :=~, :"!~", :eql?, :to_s, - :to_str, to: :name + :to_str, :as_json, to: :name # Returns a new ActiveModel::Name instance. By default, the +namespace+ # and +name+ option will take the namespace and name of the given class |