mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Convert to model before calling model_name on a record in ActiveModel::Naming
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
b7c49cedba
commit
33aaa15f62
1 changed files with 5 additions and 1 deletions
|
@ -129,7 +129,11 @@ module ActiveModel
|
|||
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue