Allow default scope to beconfigured.

This commit is contained in:
José Valim 2009-11-19 13:09:05 -02:00
parent 8d5445579c
commit 1a8dc7fe37
5 changed files with 13 additions and 1 deletions

View File

@ -1,7 +1,11 @@
* deprecations
* Deprecate :singular in devise_for and use :scope instead
* enhancements
* [#37] Create after_sign_in_path_for and after_sign_out_path_for hooks to be
overwriten in ApplicationController
* Create sign_in_and_redirect and sign_out_and_redirect helpers
* Warden::Manager.default_scope is automatically configured to the first given scope
== 0.5.3

View File

@ -138,6 +138,9 @@ rescue
require 'warden'
end
# Set the default_scope to nil, so it's overwritten when the first route is declared.
Warden::Manager.default_scope = nil
require 'devise/strategies/base'
require 'devise/serializers/base'

View File

@ -85,6 +85,7 @@ module ActionController::Routing
resources.map!(&:to_sym)
resources.each do |resource|
mapping = Devise::Mapping.new(resource, options.dup)
Warden::Manager.default_scope ||= mapping.name
Devise.mappings[mapping.name] = mapping
route_options = mapping.route_options.merge(:path_prefix => mapping.raw_path, :name_prefix => "#{mapping.name}_")

View File

@ -66,6 +66,10 @@ class DeviseTest < ActiveSupport::TestCase
assert manager.silence_missing_strategies
end
test 'warden default scope is set' do
assert_equal :user, Warden::Manager.default_scope
end
test 'warden manager user configuration through a block' do
begin
@executed = false

View File

@ -4,7 +4,7 @@ ActionController::Routing::Routes.draw do |map|
map.devise_for :account, :path_names => {
:sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification'
}
map.devise_for :organizers, :singular => 'manager',
map.devise_for :organizers, :scope => 'manager',
:path_prefix => '/:locale',
:requirements => { :extra => 'value' }