Rename :singular option to :scope.
This commit is contained in:
parent
d445b4beb9
commit
8d5445579c
|
@ -9,8 +9,8 @@ module Devise
|
|||
base.class_eval do
|
||||
unloadable
|
||||
|
||||
helper_method :resource, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
||||
hide_action :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, :scope_name, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
||||
|
||||
skip_before_filter *Devise.mappings.keys.map { |m| :"authenticate_#{m}!" }
|
||||
before_filter :is_devise_resource?
|
||||
|
@ -26,6 +26,7 @@ module Devise
|
|||
def resource_name
|
||||
devise_mapping.name
|
||||
end
|
||||
alias :scope_name :resource_name
|
||||
|
||||
# Proxy to devise map class
|
||||
def resource_class
|
||||
|
|
|
@ -60,7 +60,7 @@ module Devise
|
|||
def initialize(name, options) #:nodoc:
|
||||
@as = (options.delete(:as) || name).to_sym
|
||||
@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_prefix = options.delete(:path_prefix) || ""
|
||||
@path_prefix << "/" unless @path_prefix[-1] == ?/
|
||||
|
|
|
@ -52,9 +52,9 @@ module ActionController::Routing
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
|
@ -77,6 +77,11 @@ module ActionController::Routing
|
|||
def devise_for(*resources)
|
||||
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.each do |resource|
|
||||
mapping = Devise::Mapping.new(resource, options.dup)
|
||||
|
|
Loading…
Reference in New Issue