diff options
author | Ernie Miller <ernie@metautonomo.us> | 2010-10-04 13:35:38 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-10-04 21:26:41 +0200 |
commit | 33aaa15f6208d65ca043ffcc5dc161d410963e9d (patch) | |
tree | c9f23fb4b3b486d761051987a8419503c6fce5ba /activemodel/lib/active_model | |
parent | b7c49cedba4a9acd001df65a102d79611598f472 (diff) | |
download | rails-33aaa15f6208d65ca043ffcc5dc161d410963e9d.tar.gz rails-33aaa15f6208d65ca043ffcc5dc161d410963e9d.tar.bz2 rails-33aaa15f6208d65ca043ffcc5dc161d410963e9d.zip |
Convert to model before calling model_name on a record in ActiveModel::Naming
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index 2d580fd325..adb71f788f 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -129,7 +129,11 @@ module ActiveModel private def self.model_name_from_record_or_class(record_or_class) - (record_or_class.is_a?(Class) ? record_or_class : record_or_class.class).model_name + (record_or_class.is_a?(Class) ? record_or_class : convert_to_model(record_or_class).class).model_name + end + + def self.convert_to_model(object) + object.respond_to?(:to_model) ? object.to_model : object end end |