Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use RouteSet mixin vs Dispatcher trick

  • Loading branch information...
commit 9f86c0db6121ca58f04576289d6cf2e2fda9d9e3 1 parent 720aa2b
@bruce bruce authored
Showing with 28 additions and 8 deletions.
  1. +25 −0 lib/fiveruns/tuneup/routing.rb
  2. +3 −8 rails/init.rb
View
25 lib/fiveruns/tuneup/routing.rb
@@ -0,0 +1,25 @@
+module Fiveruns::Tuneup
+
+ module Routing
+
+ def self.install
+ ActionController::Routing::RouteSet.send(:include, self)
+ end
+
+ def self.included(base)
+ base.alias_method_chain :draw, :fiveruns_tuneup
+ end
+ def draw_with_fiveruns_tuneup(*args, &block)
+ draw_without_fiveruns_tuneup(*args) do |map|
+ map.connect '/tuneup', :controller => 'tuneup', :action => 'show'
+ map.connect '/tuneup/:action', :controller => 'tuneup'
+ yield map
+ end
+ end
+
+ end
+
+end
+
+
+
View
11 rails/init.rb
@@ -1,13 +1,8 @@
Fiveruns::Tuneup.start do
require 'dispatcher'
- Dispatcher.to_prepare :tuneup_route do
- ActionController::Routing::Routes.add_route '/tuneup', :controller => 'tuneup', :action => 'show'
- ActionController::Routing::Routes.add_route '/tuneup/:action', :controller => 'tuneup'
- 2.times do
- route = ActionController::Routing::Routes.routes.pop
- ActionController::Routing::Routes.routes.unshift(route)
- end
- end
+
+ Fiveruns::Tuneup::Routing.install
+
Dispatcher.to_prepare :tuneup_controller_filters do
TuneupController.filter_chain.clear
TuneupController.before_filter :find_config, :except => :index
Please sign in to comment.
Something went wrong with that request. Please try again.