Method: Her::Model::Paths::ClassMethods#resource_path

Defined in:
lib/her/model/paths.rb

#resource_path(path = nil) ⇒ Object

Defines a custom resource path for the resource

Note that, if used in combination with resource_path, you may specify either the real primary key or the string ‘:id’. For example:

Examples:

class User
  include Her::Model
  resource_path "/users/:id"
end
class User
  include Her::Model
  primary_key 'user_id'

  # This works because we'll have a user_id attribute
  resource_path '/users/:user_id'

  # This works because we replace :id with :user_id
  resource_path '/users/:id'
end


80
81
82
83
84
85
86
# File 'lib/her/model/paths.rb', line 80

def resource_path(path = nil)
  if path.nil?
    @_her_resource_path ||= "#{root_element.to_s.pluralize}/:id"
  else
    @_her_resource_path = path
  end
end