Commit 9d57f745d5cc81ff30b18a2aa29e382f3eec6d0c
- Date: Wed Mar 19 09:19:25 +0000 2008
- Committer: Johan Sørensen (johan@johansorensen.com)
- Author: Johan Sørensen (johan@johansorensen.com)
- Commit SHA1: 9d57f745d5cc81ff30b18a2aa29e382f3eec6d0c
- Tree SHA1: 4cfa8780d69cef41ee615fd781557c9c0e891f7b
Catch RoutingError's gracefully
Commit diff
| |   |
| 7 | 7 | include ExceptionNotifiable |
| 8 | 8 | |
| 9 | 9 | rescue_from ActiveRecord::RecordNotFound, :with => :render_not_found |
| 10 | | rescue_from ActionController::RoutingError, :with => :render_not_found |
| 10 | rescue_from ActionController::UnknownController, :with => :render_not_found |
| 11 | rescue_from ActionController::UnknownAction, :with => :render_not_found |
| 12 | |
| 13 | def rescue_action(exception) |
| 14 | return super if RAILS_ENV != "production" |
| 15 | |
| 16 | case exception |
| 17 | # Can't catch RoutingError with rescue_from it seems, |
| 18 | # so do it the old-fashioned way |
| 19 | when ActionController::RoutingError |
| 20 | render_not_found |
| 21 | else |
| 22 | super |
| 23 | end |
| 24 | end |
| 11 | 25 | |
| 12 | 26 | protected |
| 13 | 27 | def require_user_has_ssh_keys |
| toggle raw diff |
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -7,7 +7,21 @@ class ApplicationController < ActionController::Base
include ExceptionNotifiable
rescue_from ActiveRecord::RecordNotFound, :with => :render_not_found
- rescue_from ActionController::RoutingError, :with => :render_not_found
+ rescue_from ActionController::UnknownController, :with => :render_not_found
+ rescue_from ActionController::UnknownAction, :with => :render_not_found
+
+ def rescue_action(exception)
+ return super if RAILS_ENV != "production"
+
+ case exception
+ # Can't catch RoutingError with rescue_from it seems,
+ # so do it the old-fashioned way
+ when ActionController::RoutingError
+ render_not_found
+ else
+ super
+ end
+ end
protected
def require_user_has_ssh_keys |
| |   |
| 37 | 37 | :confirm_delete => :get |
| 38 | 38 | }, :as => "repos") do |repo| |
| 39 | 39 | repo.resources :committers, :name_prefix => nil, :collection => {:auto_complete_for_user_login => :post} |
| 40 | | repo.resources :comments |
| 40 | repo.resources :comments, :member => { :commmit => :get } |
| 41 | 41 | repo.resources :merge_requests, :member => { :resolve => :put } |
| 42 | 42 | repo.commit_comment "comments/commit/:sha", :controller => "comments", |
| 43 | 43 | :action => "commit", :conditions => { :method => :get } |
| toggle raw diff |
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -37,7 +37,7 @@ ActionController::Routing::Routes.draw do |map|
:confirm_delete => :get
}, :as => "repos") do |repo|
repo.resources :committers, :name_prefix => nil, :collection => {:auto_complete_for_user_login => :post}
- repo.resources :comments
+ repo.resources :comments, :member => { :commmit => :get }
repo.resources :merge_requests, :member => { :resolve => :put }
repo.commit_comment "comments/commit/:sha", :controller => "comments",
:action => "commit", :conditions => { :method => :get } |