2016-07-07 7 views
0

アカウント確認のためにDeviseからメールに指示が送られます。ユーザーが確認リンクをクリックすると、アカウントが有効になり、ユーザーはstatic_pages#homeページにリダイレクトされますが、このリンクを他のページにリダイレクトする必要があります。Railsでconfirm_urlを変更する方法

確認URL:

<p><%= link_to 'Подтвердить мой аккаунт', confirmation_url(@resource, confirmation_token: @token) %></p> 

confirmation_controller:

/ホーム/ヴラド/デスクトップ/ MyAppに/アプリ/コントローラ/ユーザ/ confirmations_controller:ブラウザで

class Users::ConfirmationsController < Devise::ConfirmationsController 
    # GET /resource/confirmation/new 
    def new 
    super 
    end 

    # POST /resource/confirmation 
    def create 
    super 
    end 

    # GET /resource/confirmation?confirmation_token=abcdef 
    def show 
    super 
    end 

    protected 

    # The path used after resending confirmation instructions. 
    def after_resending_confirmation_instructions_path_for(resource_name) 
    super(resource_name) 
    end 

    # The path used after confirmation. 
    def after_confirmation_path_for(resource_name, resource) 
    new_profiles_path (resource_name, resource) 
    end 

end 

新しいエラー.rb:26: 予期しない '、'、expecting ')' new_profiles_path (リソース名、リソース)^

答えて

0

あなたが代わりにあなたはそれがapp/controllersconfirmations_controller.rbを作成するためにはConfirmationsController

after_confirmation_path_forを定義する必要があることを行うにはafter_confirmation_path_for

をオーバーライドする必要がconfirmation_urlを変更する必要がいけませんディレクトリ:config/routes.rb

class ConfirmationsController  < Devise::ConfirmationsController 

    private 

    def  after_confirmation_path_for(resource_name, resource) 
     your_new_after_confirmation_path 
    end 

end 

は、このラインSを追加しますo DeviseはカスタムのConfirmationsControllerを使用します。

devise_for :users, controllers: { confirmations: 'confirmations' } 

Webサーバーを再起動する必要があります。 /ホーム/ヴラド/デスクトップ/ MyAppに/アプリ/コントローラ -

Devise Wikiここ

を更新

より多くのオプション/詳細

用を参照してくださいあなたの命令、新しいエラーの後confirmations_controller.rb

class Users::ConfirmationsController < Devise::ConfirmationsController 
# GET /resource/confirmation/new 
def new 
super 
end 
# POST /resource/confirmation 
def create 
    super 
end 

# GET /resource/confirmation?confirmation_token=abcdef 
def show 
super 
end 

protected # The path used after resending confirmation instructions. 
def after_resending_confirmation_instructions_path_for(resource_name) 
super(resource_name) 
end 

# The path used after confirmation. 
def after_confirmation_path_for(resource_name, resource) 
new_profiles_path(resource_name, resource) 
end 
end 
+0

です/ new_profiles_path(resource_name、resource)^ –

+0

これは私の今のコードです: nfirmation_path_for(resource_name、resource) new_profiles_path(resource_name、resource) end –

+0

構文エラーが発生したようです。あなたの質問に 'confirmations_controller.rb'のコードスニペットを貼り付けてください。コメントでは、それは可読ではない –

関連する問題