Permalink
Browse files

remove old routing hack. replace with Clearance::Routes.draw(map) to …

…give more control to the application developer.
  • Loading branch information...
1 parent c73d1df commit 8f355a3f96ec9323d7f87da7fbe298ecefbddf1e @croaky croaky committed Jan 19, 2010
Showing with 53 additions and 53 deletions.
  1. +0 −6 TODO.textile
  2. +0 −30 config/clearance_routes.rb
  3. +1 −1 lib/clearance.rb
  4. +0 −14 lib/clearance/extensions/routes.rb
  5. +49 −0 lib/clearance/routes.rb
  6. +3 −2 test/rails_root/config/routes.rb
View
@@ -1,6 +0,0 @@
-h1. To-do
-
-* Make insertion of Clearance::User into User model automatic from the generator.
-* Change generated README to include instruction about running the migration.
-* DO_NOT_REPLY, HOST refactoring.
-
@@ -1,30 +0,0 @@
-ActionController::Routing::Routes.draw do |map|
- map.resources :passwords,
- :controller => 'clearance/passwords',
- :only => [:new, :create]
-
- map.resource :session,
- :controller => 'clearance/sessions',
- :only => [:new, :create, :destroy]
-
- map.resources :users, :controller => 'clearance/users' do |users|
- users.resource :password,
- :controller => 'clearance/passwords',
- :only => [:create, :edit, :update]
-
- users.resource :confirmation,
- :controller => 'clearance/confirmations',
- :only => [:new, :create]
- end
-
- map.sign_up 'sign_up',
- :controller => 'clearance/users',
- :action => 'new'
- map.sign_in 'sign_in',
- :controller => 'clearance/sessions',
- :action => 'new'
- map.sign_out 'sign_out',
- :controller => 'clearance/sessions',
- :action => 'destroy',
- :method => :delete
-end
View
@@ -1,6 +1,6 @@
require 'clearance/extensions/errors'
require 'clearance/extensions/rescue'
-require 'clearance/extensions/routes'
+require 'clearance/routes'
require 'clearance/authentication'
require 'clearance/user'
@@ -1,14 +0,0 @@
-if defined?(ActionController::Routing::RouteSet)
- class ActionController::Routing::RouteSet
- def load_routes_with_clearance!
- lib_path = File.dirname(__FILE__)
- clearance_routes = File.join(lib_path, *%w[.. .. .. config clearance_routes.rb])
- unless configuration_files.include?(clearance_routes)
- add_configuration_file(clearance_routes)
- end
- load_routes_without_clearance!
- end
-
- alias_method_chain :load_routes!, :clearance
- end
-end
@@ -0,0 +1,49 @@
+module Clearance
+ class Routes
+
+ # In your application's config/routes.rb, draw Clearance's routes:
+ #
+ # @example
+ # map.resources :posts
+ # Clearance::Routes.draw(map)
+ #
+ # If you need to override a Clearance route, invoke your app route
+ # earlier in the file so Rails' router short-circuits when it finds
+ # your route:
+ #
+ # @example
+ # map.resources :users, :only => [:new, :create]
+ # Clearance::Routes.draw(map)
+ def self.draw(map)
+ map.resources :passwords,
+ :controller => 'clearance/passwords',
+ :only => [:new, :create]
+
+ map.resource :session,
+ :controller => 'clearance/sessions',
+ :only => [:new, :create, :destroy]
+
+ map.resources :users, :controller => 'clearance/users' do |users|
+ users.resource :password,
+ :controller => 'clearance/passwords',
+ :only => [:create, :edit, :update]
+
+ users.resource :confirmation,
+ :controller => 'clearance/confirmations',
+ :only => [:new, :create]
+ end
+
+ map.sign_up 'sign_up',
+ :controller => 'clearance/users',
+ :action => 'new'
+ map.sign_in 'sign_in',
+ :controller => 'clearance/sessions',
+ :action => 'new'
+ map.sign_out 'sign_out',
+ :controller => 'clearance/sessions',
+ :action => 'destroy',
+ :method => :delete
+ end
+
+ end
+end
@@ -1,5 +1,6 @@
ActionController::Routing::Routes.draw do |map|
- map.resource :account
-
+ map.resource :account
map.root :controller => 'accounts', :action => 'edit'
+
+ Clearance::Routes.draw(map)
end

0 comments on commit 8f355a3

Please sign in to comment.