diff options
author | José Valim <jose.valim@gmail.com> | 2009-12-02 22:47:09 -0200 |
---|---|---|
committer | Yehuda Katz <wycats@Yehuda-Katz.local> | 2009-12-07 15:05:27 -0800 |
commit | 2ecfa817c95f98247d1bd7fb28b208d3f950b43f (patch) | |
tree | f2f85c7e425e94cdd3f3ca23f2d49ff762cfb8fb /actionpack/lib/action_controller | |
parent | 324fa688fcd8f5b6a8e9a0226b0cb3d2829e122c (diff) | |
download | rails-2ecfa817c95f98247d1bd7fb28b208d3f950b43f.tar.gz rails-2ecfa817c95f98247d1bd7fb28b208d3f950b43f.tar.bz2 rails-2ecfa817c95f98247d1bd7fb28b208d3f950b43f.zip |
Responder redirects to resource if destroy fails.
Signed-off-by: Yehuda Katz <wycats@Yehuda-Katz.local>
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/metal/responder.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/responder.rb b/actionpack/lib/action_controller/metal/responder.rb index 6c76c57839..cb0e600871 100644 --- a/actionpack/lib/action_controller/metal/responder.rb +++ b/actionpack/lib/action_controller/metal/responder.rb @@ -80,6 +80,11 @@ module ActionController #:nodoc: class Responder attr_reader :controller, :request, :format, :resource, :resources, :options + ACTIONS_FOR_VERBS = { + :post => :new, + :put => :edit + } + def initialize(controller, resources, options={}) @controller = controller @request = controller.request @@ -138,7 +143,7 @@ module ActionController #:nodoc: def navigation_behavior(error) if get? raise error - elsif has_errors? + elsif has_errors? && default_action render :action => default_action else redirect_to resource_location @@ -209,7 +214,7 @@ module ActionController #:nodoc: # the verb is post. # def default_action - @action || (request.post? ? :new : :edit) + @action ||= ACTIONS_FOR_VERBS[request.method] end end end |