Browse files

Merge pull request #9 from menkel/master

Feature mount_sextant  for counteract catch-all route method
  • Loading branch information...
2 parents 0225889 + c161beb commit c5d40d1a6c81f2cd61f70240b5a0b6a3bb3fa9b1 @schneems committed Jun 1, 2012
View
9 README.md
@@ -30,6 +30,15 @@ end
Then run `bundle install` and you're ready to start
+### Optional for user of catch-all route in routes.rb:
+
+Add sextant to your routes (config/routes.rb) before catch-all routes
+
+```ruby
+mount_sextant
+match '*not_found' => 'errors#handle404'
+match "*path" => 'errors#handle404'
+```
## Use
View
6 config/routes.rb
@@ -1,9 +1,7 @@
Rails.application.routes.draw do
- namespace :rails do
- resources :routes, :only => [:index, :show]
- end
+ mount_sextant
end
# RouteInspector::Engine.routes.draw do
-#
+#
# end
View
11 lib/rails/routes.rb
@@ -0,0 +1,11 @@
+module ActionDispatch::Routing
+ class Mapper
+ # Includes mount_sextant method for routes. This method is responsible to
+ # generate all needed routes for sextant
+ def mount_sextant
+ namespace :rails do
+ resources :routes, :only => [:index, :show]
+ end
+ end
+ end
+end
View
1 lib/sextant.rb
@@ -1,5 +1,6 @@
require 'rails/application/route_inspector'
require 'sextant/engine'
+require 'rails/routes'
module Sextant
def self.format_routes(routes = all_routes)
View
4 test/dummy/app/controllers/foo_controller.rb
@@ -0,0 +1,4 @@
+class FooController < ApplicationController
+ def index
+ end
+end
View
4 test/dummy/app/foo_controller.rb
@@ -0,0 +1,4 @@
+class FooController < ApplicationController
+ def index
+ end
+end
View
0 test/dummy/app/views/foo/index.html
No changes.
View
3 test/dummy/config/routes.rb
@@ -2,6 +2,9 @@
resources :foo
resources :bar
+ mount_sextant
+
+ match '*a', :to => 'foo#index'
# The priority is based upon order of creation:
# first created -> highest priority.

0 comments on commit c5d40d1

Please sign in to comment.