Method: ActiveResource::Singleton::ClassMethods#singleton_path
- Defined in:
- lib/active_resource/singleton.rb
#singleton_path(prefix_options = {}, query_options = nil) ⇒ Object
Gets the singleton path for the object. If the query_options parameter is omitted, Rails will split from the prefix options.
Options
prefix_options - A hash to add a prefix to the request for nested URLs (e.g., :account_id => 19
would yield a URL like <tt>/accounts/19/purchases.json</tt>).
query_options - A hash to add items to the query string for the request.
Examples
Weather.singleton_path
# => /weather.json
class Inventory < ActiveResource::Base
self.site = "https://37s.sunrise.com"
self.prefix = "/products/:product_id/"
end
Inventory.singleton_path(:product_id => 5)
# => /products/5/inventory.json
Inventory.singleton_path({:product_id => 5}, {:sold => true})
# => /products/5/inventory.json?sold=true
35 36 37 38 39 40 |
# File 'lib/active_resource/singleton.rb', line 35 def singleton_path( = {}, = nil) () , = () if .nil? "#{prefix(prefix_options)}#{singleton_name}.#{format.extension}#{query_string(query_options)}" end |