Class: Resourceize::ResourcesController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Resourceize::ResourcesController
- Includes:
- Before, InstanceVariables, RoutingMethods
- Defined in:
- lib/resourceize/resources_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods included from RoutingMethods
Methods included from InstanceVariables
Methods included from Before
Class Method Details
.follow(action, &block) ⇒ Object
32 33 34 35 36 |
# File 'lib/resourceize/resources_controller.rb', line 32 def self.follow(action, &block) action = :"#{action}" @follow ||= {} @follow[action] = block end |
.set_resource(resource_class) ⇒ Object
28 29 30 |
# File 'lib/resourceize/resources_controller.rb', line 28 def self.set_resource(resource_class) request.instance_eval {@resource = resource_class} end |
Instance Method Details
#create ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/resourceize/resources_controller.rb', line 54 def create if @object.save success :redirect_to => follow_action(:create) || (can_render_show? ? object_path(@object) : collection_path) else failure :render => template_for("new") end end |
#destroy ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/resourceize/resources_controller.rb', line 72 def destroy if @object.destroy success :redirect_to => follow_action(:destroy) || collection_path else failure :redirect_to => collection_path end end |
#edit ⇒ Object
44 45 46 |
# File 'lib/resourceize/resources_controller.rb', line 44 def edit render :template => template_for("edit") end |
#index ⇒ Object
49 50 51 |
# File 'lib/resourceize/resources_controller.rb', line 49 def index render :template => template_for("index") end |
#new ⇒ Object
39 40 41 |
# File 'lib/resourceize/resources_controller.rb', line 39 def new render :template => template_for("new") end |
#show ⇒ Object
81 82 83 |
# File 'lib/resourceize/resources_controller.rb', line 81 def show end |
#update ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/resourceize/resources_controller.rb', line 63 def update if @object.update_attributes(params[:"#{request.resource_name}"]) success :redirect_to => follow_action(:update) || (can_render_show? ? object_path(@object) : collection_path) else failure :render => template_for("edit") end end |