2009-10-09 20:11:58 -04:00
|
|
|
module Devise
|
|
|
|
module Controllers
|
2009-10-18 10:54:21 -04:00
|
|
|
# Create url helpers to be used with resource/scope configuration. Acts as
|
|
|
|
# proxies to the generated routes created by devise.
|
|
|
|
# Resource param can be a string or symbol, a class, or an instance object.
|
|
|
|
# Example using a :user resource:
|
|
|
|
#
|
|
|
|
# new_session_path(:user) => new_user_session_path
|
|
|
|
# session_path(:user) => user_session_path
|
|
|
|
# destroy_session_path(:user) => destroy_user_session_path
|
|
|
|
#
|
|
|
|
# new_password_path(:user) => new_user_password_path
|
|
|
|
# password_path(:user) => user_password_path
|
|
|
|
# edit_password_path(:user) => edit_user_password_path
|
|
|
|
#
|
|
|
|
# new_confirmation_path(:user) => new_user_confirmation_path
|
|
|
|
# confirmation_path(:user) => user_confirmation_path
|
2009-10-27 19:26:40 -04:00
|
|
|
#
|
|
|
|
# Those helpers are added to your ApplicationController.
|
2009-10-09 20:11:58 -04:00
|
|
|
module UrlHelpers
|
|
|
|
|
2010-07-13 04:09:55 -04:00
|
|
|
Devise::URL_HELPERS.each do |module_name, actions|
|
2009-10-09 20:11:58 -04:00
|
|
|
[:path, :url].each do |path_or_url|
|
|
|
|
actions.each do |action|
|
2010-07-13 04:09:55 -04:00
|
|
|
action = action ? "#{action}_" : ""
|
|
|
|
|
2010-02-08 14:25:20 -05:00
|
|
|
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
|
2010-01-23 19:47:33 -05:00
|
|
|
def #{action}#{module_name}_#{path_or_url}(resource_or_scope, *args)
|
|
|
|
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
|
|
|
send("#{action}\#{scope}_#{module_name}_#{path_or_url}", *args)
|
2009-10-09 20:11:58 -04:00
|
|
|
end
|
|
|
|
URL_HELPERS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-10-11 21:11:58 -04:00
|
|
|
|
2009-10-09 20:11:58 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|