ruby on rails - catching wild card route for missing routes, doesn't work when having additional routes files -
i implemented simple custom errors solution. one: http://ramblinglabs.com/blog/2012/01/rails-3-1-adding-custom-404-and-500-error-pages
everyhing working fine except missing routes in routes.rb file..
in order error_controller when there missing route did wildcard solution: match '*not_found', to: 'errors#error_404'
but... when seek come in sub section of site seats under: /admin, error page. wilcard gets triggered, tough route admin section defined in different route file, under: config/routes/admin.rb
what can do? thanks
edit: using rails 3.0.20 , ruby 1.8.7
if you're using rails 3.2+, there simpler solution routes. first in 'config/application.rb' set app error handler
config.exceptions_app = self.routes
now when there app routes handle it. in 'config/routes.rb' can add together route such as:
match "/404", :to => "errors#not_found"
a more verbose explanation can found here.
ruby-on-rails ruby-on-rails-3 routes
No comments:
Post a Comment