mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Rename :singular option to :scope.
This commit is contained in:
parent
d445b4beb9
commit
8d5445579c
3 changed files with 11 additions and 5 deletions
|
@ -9,8 +9,8 @@ module Devise
|
||||||
base.class_eval do
|
base.class_eval do
|
||||||
unloadable
|
unloadable
|
||||||
|
|
||||||
helper_method :resource, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
helper_method :resource, :scope_name, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
||||||
hide_action :resource, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
hide_action :resource, :scope_name, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
||||||
|
|
||||||
skip_before_filter *Devise.mappings.keys.map { |m| :"authenticate_#{m}!" }
|
skip_before_filter *Devise.mappings.keys.map { |m| :"authenticate_#{m}!" }
|
||||||
before_filter :is_devise_resource?
|
before_filter :is_devise_resource?
|
||||||
|
@ -26,6 +26,7 @@ module Devise
|
||||||
def resource_name
|
def resource_name
|
||||||
devise_mapping.name
|
devise_mapping.name
|
||||||
end
|
end
|
||||||
|
alias :scope_name :resource_name
|
||||||
|
|
||||||
# Proxy to devise map class
|
# Proxy to devise map class
|
||||||
def resource_class
|
def resource_class
|
||||||
|
|
|
@ -60,7 +60,7 @@ module Devise
|
||||||
def initialize(name, options) #:nodoc:
|
def initialize(name, options) #:nodoc:
|
||||||
@as = (options.delete(:as) || name).to_sym
|
@as = (options.delete(:as) || name).to_sym
|
||||||
@klass = (options.delete(:class_name) || name.to_s.classify).to_s
|
@klass = (options.delete(:class_name) || name.to_s.classify).to_s
|
||||||
@name = (options.delete(:singular) || name.to_s.singularize).to_sym
|
@name = (options.delete(:scope) || name.to_s.singularize).to_sym
|
||||||
@path_names = options.delete(:path_names) || {}
|
@path_names = options.delete(:path_names) || {}
|
||||||
@path_prefix = options.delete(:path_prefix) || ""
|
@path_prefix = options.delete(:path_prefix) || ""
|
||||||
@path_prefix << "/" unless @path_prefix[-1] == ?/
|
@path_prefix << "/" unless @path_prefix[-1] == ?/
|
||||||
|
|
|
@ -52,9 +52,9 @@ module ActionController::Routing
|
||||||
#
|
#
|
||||||
# map.devise_for :users, :as => 'accounts'
|
# map.devise_for :users, :as => 'accounts'
|
||||||
#
|
#
|
||||||
# * :singular => setup the name used to create named routes. By default, for a :users key, it is going to be the singularized version, :user. To configure a named route like account_session_path instead of user_session_path just do:
|
# * :scope => setup the scope name. This is used as the instance variable name in controller, as the name in routes and the scope given to warden. Defaults to the singular of the given name:
|
||||||
#
|
#
|
||||||
# map.devise_for :users, :singular => :account
|
# map.devise_for :users, :scope => :account
|
||||||
#
|
#
|
||||||
# * :path_names => configure different path names to overwrite defaults :sign_in, :sign_out, :password and :confirmation.
|
# * :path_names => configure different path names to overwrite defaults :sign_in, :sign_out, :password and :confirmation.
|
||||||
#
|
#
|
||||||
|
@ -77,6 +77,11 @@ module ActionController::Routing
|
||||||
def devise_for(*resources)
|
def devise_for(*resources)
|
||||||
options = resources.extract_options!
|
options = resources.extract_options!
|
||||||
|
|
||||||
|
if singular = options.delete(:singular)
|
||||||
|
ActiveSupport::Deprecation.warn ":singular is deprecated in devise_for, use :scope instead."
|
||||||
|
options[:scope] = singular
|
||||||
|
end
|
||||||
|
|
||||||
resources.map!(&:to_sym)
|
resources.map!(&:to_sym)
|
||||||
resources.each do |resource|
|
resources.each do |resource|
|
||||||
mapping = Devise::Mapping.new(resource, options.dup)
|
mapping = Devise::Mapping.new(resource, options.dup)
|
||||||
|
|
Loading…
Reference in a new issue