Skip to content
This repository
Browse code

Convert to model before calling model_name on a record in ActiveModel…

…::Naming

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit 33aaa15f6208d65ca043ffcc5dc161d410963e9d 1 parent b7c49ce
Ernie Miller authored October 04, 2010 josevalim committed October 04, 2010

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  activemodel/lib/active_model/naming.rb
6  activemodel/lib/active_model/naming.rb
@@ -129,7 +129,11 @@ def self.param_key(record_or_class)
129 129
 
130 130
     private
131 131
       def self.model_name_from_record_or_class(record_or_class)
132  
-        (record_or_class.is_a?(Class) ? record_or_class : record_or_class.class).model_name
  132
+        (record_or_class.is_a?(Class) ? record_or_class : convert_to_model(record_or_class).class).model_name
  133
+      end
  134
+
  135
+      def self.convert_to_model(object)
  136
+        object.respond_to?(:to_model) ? object.to_model : object
133 137
       end
134 138
   end
135 139
 

0 notes on commit 33aaa15

Please sign in to comment.
Something went wrong with that request. Please try again.