Module Resourceful::Default::Actions
In: lib/resourceful/default/actions.rb

Contains the definitions of the default resourceful actions. These are made available with the Builder#actions method.

These methods are very compact, so the best way to understand them is just to look at their source. Check out Resourceful::Accessors and Resourceful::Callbacks for the documentation of the methods called within the actions.

Along with each action is listed the RESTful method which corresponds to the action. The controller in the examples is FoosController, and the id for single-object actions is 12.

Methods

create   destroy   edit   index   new   show   update  

Public Instance methods

POST /foos

[Source]

    # File lib/resourceful/default/actions.rb, line 33
33:       def create
34:         build_object
35:         load_object
36:         before :create
37:         if current_object.save
38:           save_succeeded!
39:           after :create
40:           response_for :create
41:         else
42:           save_failed!
43:           after :create_fails
44:           response_for :create_fails
45:         end
46:       end

DELETE /foos/12

[Source]

    # File lib/resourceful/default/actions.rb, line 79
79:       def destroy
80:         load_object
81:         before :destroy
82:         if current_object.destroy
83:           after :destroy
84:           response_for :destroy
85:         else
86:           after :destroy_fails
87:           response_for :destroy_fails
88:         end
89:       end

GET /foos/12/edit

[Source]

    # File lib/resourceful/default/actions.rb, line 72
72:       def edit
73:         load_object
74:         before :edit
75:         response_for :edit
76:       end

GET /foos

[Source]

    # File lib/resourceful/default/actions.rb, line 17
17:       def index
18:         load_objects
19:         before :index
20:         response_for :index
21:       end

GET /foos/new

[Source]

    # File lib/resourceful/default/actions.rb, line 64
64:       def new
65:         build_object
66:         load_object
67:         before :new
68:         response_for :new
69:       end

GET /foos/12

[Source]

    # File lib/resourceful/default/actions.rb, line 24
24:       def show
25:         load_object
26:         before :show
27:         response_for :show
28:       rescue
29:         response_for :show_fails
30:       end

PUT /foos/12

[Source]

    # File lib/resourceful/default/actions.rb, line 49
49:       def update
50:         load_object
51:         before :update
52:         if current_object.update_attributes object_parameters
53:           save_succeeded!
54:           after :update
55:           response_for :update
56:         else
57:           save_failed!
58:           after :update_fails
59:           response_for :update_fails
60:         end
61:       end

[Validate]