diff options
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index 2102282c02..c0d93e5d53 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -298,12 +298,15 @@ module ActiveModel model_name_from_record_or_class(record_or_class).param_key end - private - def self.model_name_from_record_or_class(record_or_class) - return record_or_class.model_name if record_or_class.respond_to?(:model_name) - return record_or_class.to_model.class.model_name if record_or_class.respond_to?(:to_model) + def self.model_name_from_record_or_class(record_or_class) #:nodoc: + if record_or_class.respond_to?(:model_name) + record_or_class.model_name + elsif record_or_class.respond_to?(:to_model) + record_or_class.to_model.class.model_name + else record_or_class.class.model_name end + end + private_class_method :model_name_from_record_or_class end - end |