Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Aug 08, 2012
@Bertg Bertg Naming helpers should first check if passed object responds to model_…
…name
920d9ee
@tenderlove tenderlove Merge pull request #7293 from Bertg/activemodel_naming_helpers_try_mo…
…del_name_first

Naming helpers should first check if passed object responds to model_name
2da242f
Showing with 3 additions and 5 deletions.
  1. +3 −5 activemodel/lib/active_model/naming.rb
View
8 activemodel/lib/active_model/naming.rb
@@ -300,11 +300,9 @@ 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 : 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

No commit comments for this range

Something went wrong with that request. Please try again.