2014-01-28 3 views
0

고안의 확인 메일보기는 다음과 같습니다유증 3.2 : 궁리 메일보기에 추가로 값을 전달하는 방법

<p>Welcome <%= @email %>!</p> 

<p>You can confirm your account email through the link below:</p> 

<p><%= link_to 'Confirm my account', 
     confirmation_url(@resource, :confirmation_token => @token) %></p> 

는 내가 필요 할 걸요 추가 값을 기반으로 몇 가지 IF/ELSE 로직을 소개합니다 여기에 입력하십시오 (이보기에서 이미 사용할 수있는 @email, @resource, @token 제외).

이보기에 추가 값을 전달하려면 어떻게해야합니까?

답변

2

현재 (Devise 3.2) 사용자 지정 "MyMailer"(https://github.com/plataformatec/devise/wiki/How-To:-Use-custom-mailer 사용) 및 메일 뷰를 작성하여 최상의 유연성을 얻을 수있는 최상의 솔루션 인 것 같습니다.

은 가져 오려면 확인 토큰 @token (새 고안 3 년 이후) 사용자 정의 메일보기에, 당신은 당신의 사용자 모델 (자원), 즉 일부 메서드를 작성해야합니다

def custom_generate_confirmation_token! 
    generate_confirmation_token! 

    return @raw_confirmation_token 
end 

def generate_confirmation_token! 
    super 
    # executes original method, from: 
    # https://github.com/plataformatec/devise/blob/master/lib/devise/models/confirmable.rb#L227 
end 

... 컨트롤러에서 다음과 같이 사용하십시오.

+0

Perfect! 약 1 시간 동안 이것을 찾고있었습니다. – robertmiles3