3a3951a3a8
The current implementation of _to_partial_path composes the part of two bits, `collection' and `element'. ActiveModel::Name also contains these fields, and they are derived the same way _to_partial_path does it. However, _to_partial_path doesn't use the information in model_name, and solely relies on its own computations instead. This works for all standard cases, but not necessarily for models that provide a non-standard model_name. This commit fixes that and has _to_partial_path use model_name if the class responds to it.
23 lines
436 B
Ruby
23 lines
436 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Helicopter
|
|
include ActiveModel::Conversion
|
|
end
|
|
|
|
class Helicopter::Comanche
|
|
include ActiveModel::Conversion
|
|
end
|
|
|
|
class Helicopter::Apache
|
|
include ActiveModel::Conversion
|
|
|
|
class << self
|
|
def model_name
|
|
@model_name ||= ActiveModel::Name.new(self).tap do |model_name|
|
|
model_name.collection = "attack_helicopters"
|
|
model_name.element = "ah-64"
|
|
end
|
|
end
|
|
end
|
|
end
|