2014-04-03 5 views
1

내 로컬 호스트에서 테스트 중입니다. 여기기본 URL 작동 중 메일러가 작동하지 않습니다.

config.action_mailer.delivery_method = :smtp 

config.action_mailer.smtp_settings = { 
    :address => "smtp.mandrillapp.com", 
    :port  => 587, 
    :user_name => "[email protected], 
    :password => ENV['MANDRILL_API_KEY'], 

} 

config.action_mailer.default_url_options = { :host => 'localhost:3000' } 

과 action_mailer 파일입니다 : 여기 내 development.rb 파일의 action_mailer 부분이다

def confirm_email(user, school, email) 
    @user = user 
    @school = school 
    @email = email 
    @url = 'http://example.com/login' 
    mail(to: @email, subject: 'Please confirm your additional school email.') 
end 

을 여기에서 볼 수 있습니다 : 이메일은

<!DOCTYPE html> 
<html> 
    <head> 
    <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /> 
    </head> 
    <body> 
    <h1>Hello <%= @user.first_name %></h1> 

    <p> 
     To confirm your additional school, <%= link_to "click here", verify_other_school_path(@school) %>. 
    </p> 
    <p>Thanks and have a great day!</p> 
    </body> 
</html> 

을하고있다 보내고. 대신이해야하는 방식의

<a href="http://verifyotherschool/4" target="_blank">click here</a> 

:

<a href="http://localhost:3000/verifyotherschool/4" target="_blank">click here</a> 

가 어떻게이 문제를 해결 할 유일한 문제는 링크에 대해 생성 된 HTML의 모습이다?

답변

3

path은 상대적인 것이며 url은 절대적인 것을 기억하십시오.
대신

verify_other_school_path(@school) 

사용

verify_other_school_url(@school) 

또는

verify_other_school_path(only_path: false, @school) 

읽기 this

+0

큰, 고마워요. – Philip7899

관련 문제