aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/naming.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb
index 7ba439fb3e..2102282c02 100644
--- a/activemodel/lib/active_model/naming.rb
+++ b/activemodel/lib/active_model/naming.rb
@@ -300,11 +300,9 @@ module ActiveModel
private
def self.model_name_from_record_or_class(record_or_class)
- (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
+ 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)
+ record_or_class.class.model_name
end
end