Sha256: 376019d28b7f27418cc68253d507b9539156491ae91f37576318a3ff35f9697d

Contents?: true

Size: 1.72 KB

Versions: 31

Compression:

Stored size: 1.72 KB

Contents

module Devise
  module Controllers
    # 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
    #
    # Those helpers are added to your ApplicationController.
    module UrlHelpers

      [:session, :password, :confirmation].each do |module_name|
        [:path, :url].each do |path_or_url|
          actions = [ nil, :new_ ]
          actions << :edit_    if module_name == :password
          actions << :destroy_ if module_name == :session

          actions.each do |action|
            class_eval <<-URL_HELPERS
              def #{action}#{module_name}_#{path_or_url}(resource, *args)
                resource = case resource
                  when Symbol, String
                    resource
                  when Class
                    resource.name.underscore
                  else
                    resource.class.name.underscore
                end

                send("#{action}\#{resource}_#{module_name}_#{path_or_url}", *args)
              end
            URL_HELPERS
          end
        end
      end

    end
  end
end

Version data entries

31 entries across 31 versions & 3 rubygems

Version Path
devise-0.8.2 lib/devise/controllers/url_helpers.rb
devise-0.8.1 lib/devise/controllers/url_helpers.rb
devise-0.8.0 lib/devise/controllers/url_helpers.rb
devise-0.7.5 lib/devise/controllers/url_helpers.rb
devise-0.7.4 lib/devise/controllers/url_helpers.rb
devise-0.7.3 lib/devise/controllers/url_helpers.rb
devise-0.7.2 lib/devise/controllers/url_helpers.rb
devise-0.7.1 lib/devise/controllers/url_helpers.rb
devise-0.7.0 lib/devise/controllers/url_helpers.rb
devise-0.6.3 lib/devise/controllers/url_helpers.rb
devise-0.6.2 lib/devise/controllers/url_helpers.rb
devise-0.6.1 lib/devise/controllers/url_helpers.rb
devise-0.6.0 lib/devise/controllers/url_helpers.rb
devise-0.5.6 lib/devise/controllers/url_helpers.rb
devise-0.5.5 lib/devise/controllers/url_helpers.rb
devise-0.5.4 lib/devise/controllers/url_helpers.rb
devise-0.5.3 lib/devise/controllers/url_helpers.rb
devise-0.5.2 lib/devise/controllers/url_helpers.rb
devise-0.5.1 lib/devise/controllers/url_helpers.rb
devise-0.5.0 lib/devise/controllers/url_helpers.rb