1

認証にdevise 2.0.0を使用するRails 3.2.8アプリケーションがあります。このアプリケーションにrefinerycmsを統合しました。これは正常に統合されました。問題は、ユーザーがヒットしたときです。

localhost/refineryRefinery のログイン ページに移動しますが、ログインに成功すると、refinerycms のダッシュボード ページではなく、アプリケーションのホームページにリダイレクトされます。

そのため、製油所のログイン手順が成功した後、製油所のダッシュボードにリダイレクトする方法を知りたいです。私はルートマウントを持っていますRefinery::Core::Engine

:at => '/' root to:'projects#index'

4

1 に答える 1

0

ユーザーがログインすると、ユーザーを目的の場所にリダイレクトするカスタム デバイス コントローラーを作成します。

カスタムコントローラーを作成します: controllers/users/sessions_controller.rb

  class Users::SessionsController < Devise::SessionsController

  before_filter :authenticate_user!, :only => [:destroy] 

  def new 
    super
  end

  def create
      #Can edit this for custom redirect
      super
  end

  def destroy
    super
  end

  protected

  def stub_options(resource)
     methods = resource_class.authentication_keys.dup
     methods = methods.keys if methods.is_a?(Hash)
     methods << :password if resource.respond_to?(:password)
     { :methods => methods, :only => [:password] }
  end

  def after_sign_in_path_for(resource)
      #Can edit this for custom redirect
      super
  end

  def after_sign_out_path_for(resource)
    super
  end

  private

end

次に、routes.rb でそのコントローラーを使用するように devise に指示します。

devise_for :users, :controllers => {:sessions => "users/sessions"}
于 2012-10-10T02:57:21.670 に答える