Skip to content

Commit

Permalink
Convert to model before calling model_name on a record in ActiveModel…
Browse files Browse the repository at this point in the history
…::Naming

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
Ernie Miller authored and josevalim committed Oct 4, 2010
1 parent b7c49ce commit 33aaa15
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion activemodel/lib/active_model/naming.rb
Expand Up @@ -129,7 +129,11 @@ def self.param_key(record_or_class)

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

Expand Down

0 comments on commit 33aaa15

Please sign in to comment.