ActiveResource::Base.element_path
パスを作成するメソッドは次のとおりです。
def element_path(id, prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}#{collection_name}/#{URI.escape id.to_s}.#{format.extension}#{query_string(query_options)}"
end
element_pathを再定義するクラスを作成します。次のようになります。
class CustomApiPath < ActiveResource::Base
def element_path(id, prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}#{URI.escape id.to_s}/#{collection_name}.#{format.extension}#{query_string(query_options)}"
end
end
(警告:テストされていません)その後、他のActiveResourceモデルはActiveResource::BaseではなくCustomApiPathから継承します。