Module: InheritedResources::Actions
- Defined in:
- lib/inherited_resources/actions.rb
Overview
Holds all default actions for InheritedResources.
Instance Method Summary collapse
-
#create(options = {}, &block) ⇒ Object
(also: #create!)
POST /resources.
-
#destroy(options = {}, &block) ⇒ Object
(also: #destroy!)
DELETE /resources/1.
-
#edit(options = {}, &block) ⇒ Object
(also: #edit!)
GET /resources/1/edit.
-
#index(options = {}, &block) ⇒ Object
(also: #index!)
GET /resources.
-
#new(options = {}, &block) ⇒ Object
(also: #new!)
GET /resources/new.
-
#show(options = {}, &block) ⇒ Object
(also: #show!)
GET /resources/1.
-
#update(options = {}, &block) ⇒ Object
(also: #update!)
PUT /resources/1.
Instance Method Details
#create(options = {}, &block) ⇒ Object Also known as: create!
POST /resources
32 33 34 35 36 37 38 39 40 |
# File 'lib/inherited_resources/actions.rb', line 32 def create(={}, &block) object = build_resource if create_resource(object) [:location] ||= smart_resource_url end respond_with_dual_blocks(object, , &block) end |
#destroy(options = {}, &block) ⇒ Object Also known as: destroy!
DELETE /resources/1
56 57 58 59 60 61 62 |
# File 'lib/inherited_resources/actions.rb', line 56 def destroy(={}, &block) object = resource [:location] ||= smart_collection_url destroy_resource(object) respond_with_dual_blocks(object, , &block) end |
#edit(options = {}, &block) ⇒ Object Also known as: edit!
GET /resources/1/edit
26 27 28 |
# File 'lib/inherited_resources/actions.rb', line 26 def edit(={}, &block) respond_with(*with_chain(resource), , &block) end |
#index(options = {}, &block) ⇒ Object Also known as: index!
GET /resources
8 9 10 |
# File 'lib/inherited_resources/actions.rb', line 8 def index(={}, &block) respond_with(*with_chain(collection), , &block) end |
#new(options = {}, &block) ⇒ Object Also known as: new!
GET /resources/new
20 21 22 |
# File 'lib/inherited_resources/actions.rb', line 20 def new(={}, &block) respond_with(*with_chain(build_resource), , &block) end |
#show(options = {}, &block) ⇒ Object Also known as: show!
GET /resources/1
14 15 16 |
# File 'lib/inherited_resources/actions.rb', line 14 def show(={}, &block) respond_with(*with_chain(resource), , &block) end |
#update(options = {}, &block) ⇒ Object Also known as: update!
PUT /resources/1
44 45 46 47 48 49 50 51 52 |
# File 'lib/inherited_resources/actions.rb', line 44 def update(={}, &block) object = resource if update_resource(object, resource_params) [:location] ||= smart_resource_url end respond_with_dual_blocks(object, , &block) end |