28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/devise/better_routes.rb', line 28
def self.override_registration_helpers!(registration_routes = nil)
helper_mappings = {
new_registration: 'new_#{scope}',
edit_registration: 'edit_#{current_resource_name}',
cancel_registration: 'cancel_#{current_resource_name}'
}
[:path, :url].each do |path_or_url|
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
def registration_#{path_or_url}(resource_or_scope, *args)
scope = Devise::Mapping.find_scope!(resource_or_scope)
current_resource_name = _devise_path_name(scope, "current_\#{scope}")
if respond_to?(:controller_name) && controller_name == _devise_registration_controller(scope, current_resource_name)
_devise_route_context.send("\#{current_resource_name}_#{path_or_url}", *args)
else
_devise_route_context.send("\#{scope.to_s.pluralize}_#{path_or_url}", *args)
end
end
URL_HELPERS
helper_mappings.each do |old_name, new_name|
method = "#{old_name}_#{path_or_url}"
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
def #{method}(resource_or_scope, *args)
scope = Devise::Mapping.find_scope!(resource_or_scope)
current_resource_name = _devise_path_name(scope, "current_\#{scope}")
_devise_route_context.send("#{new_name}_#{path_or_url}", *args)
end
URL_HELPERS
end
end
end
|