2016-07-07 2 views
0

계정 확인을 위해 Devise가 메일로 보내기 지시. 사용자가 확인 링크를 클릭하면 계정이 활성화되고 사용자가 static_pages#home 페이지로 리디렉션되지만이 링크를 다른 페이지로 리디렉션해야합니다.레일에서 confirmation_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 (RESOURCE_NAME, 자원)^당신은 after_confirmation_path_for

당신이 그 app/controllersconfirmations_controller.rb를 작성하려면 ConfirmationsController

after_confirmation_path_for를 정의 할 필요가 있음을하려면 오버라이드 (override) 할 필요가 대신 confirmation_url을 변경할 필요가없는

답변

0

디렉토리 :

class ConfirmationsController  < Devise::ConfirmationsController 

    private 

    def  after_confirmation_path_for(resource_name, resource) 
     your_new_after_confirmation_path 
    end 

end 

config/routes.rb에 다음 라인을 추가하십시오. o Devise는 사용자 지정 ConfirmationsController를 사용합니다.

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

웹 서버를 다시 시작해야합니다./가정/블라드/데스크탑/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

입니다 /users/confirmations_controller.rb:26 : 구문 오류, 예기치 못한 ',', 예상 ')'new_profiles_path (resource_name, resource)^ –

+0

이것은 현재 내 코드입니다 : protected def after_co nfirmation_path_for (resource_name, resource) new_profiles_path (resource_name, resource) end –

+0

구문 오류가 발생했습니다. 질문에'confirmations_controller.rb'에 대한 코드 스 니펫을 붙여주세요. 코멘트에서 읽을 수없는 것 –

관련 문제