Ensure namespaces has proper scoped views, closes #654

This commit is contained in:
José Valim
2010-11-20 21:41:26 +01:00
parent 6bfcbeffdd
commit d8016ea3fd
6 changed files with 18 additions and 7 deletions

View File

@@ -20,7 +20,7 @@ module Devise
def render_with_scope(action, path=self.controller_path)
if self.class.scoped_views?
begin
render :template => "#{devise_mapping.plural}/#{path.split("/").last}/#{action}"
render :template => "#{devise_mapping.scoped_path}/#{path.split("/").last}/#{action}"
rescue ActionView::MissingTemplate
render :template => "#{path}/#{action}"
end

View File

@@ -22,7 +22,7 @@ module Devise
# # is the modules included in the class
#
class Mapping #:nodoc:
attr_reader :singular, :plural, :path, :controllers, :path_names, :class_name, :sign_out_via
attr_reader :singular, :scoped_path, :path, :controllers, :path_names, :class_name, :sign_out_via
alias :name :singular
# Receives an object and find a scope for it. If a scope cannot be found,
@@ -46,8 +46,8 @@ module Devise
end
def initialize(name, options) #:nodoc:
@plural = (options[:as] ? "#{options[:as]}_#{name}" : name).to_sym
@singular = (options[:singular] || @plural.to_s.singularize).to_sym
@scoped_path = options[:as] ? "#{options[:as]}/#{name}" : name.to_s
@singular = (options[:singular] || @scoped_path.tr('/', '_').singularize).to_sym
@class_name = (options[:class_name] || name.to_s.classify).to_s
@ref = ActiveSupport::Dependencies.ref(@class_name)

View File

@@ -178,7 +178,7 @@ module ActionDispatch::Routing
devise_scope mapping.name do
yield if block_given?
with_devise_exclusive_scope mapping.fullpath, mapping.name do
routes.each { |mod| send(:"devise_#{mod}", mapping, mapping.controllers) }
routes.each { |mod| send("devise_#{mod}", mapping, mapping.controllers) }
end
end
end