2011-10-13 39 views
0

我已經在我的郵件如下:我怎麼可以設置郵件主機,所以我可以通過用戶一個用於生產,一個用於開發的Rails

#activate board first using a different email? 
def welcome_manager(participant) 
    @participant = participant 
    @user = participant.user 
    @board = participant.board 
    @url = birthday_url(@participant.token, :host => "birthday-greeting.net") 
    mail(:to => @user.email, :subject => "Confirmation: #{@board.bp_name.possessive} Happy Birthday Board Created") 
end 

哪些在線使用的主機。 然而,當我在開發我想使用localhost:3000,如下所示:

#activate board first using a different email? 
def welcome_manager(participant) 
    @participant = participant 
    @user = participant.user 
    @board = participant.board 
    @url = birthday_url(@participant.token, :host => "localhost:3000") 
    mail(:to => @user.email, :subject => "Confirmation: #{@board.bp_name.possessive} Happy Birthday Board Created") 
end 

我怎樣才能做到這一點?

回答

0

您應該在相應的config/environment/development.rbproduction.rb中設置您的郵件主機。

但是,如果你真的需要像內聯做的,只是使用條件上Rails.env:我需要

:host => Rails.env == "production" ? "birthday-greeting.org" : "localhost:3000" 
+0

感謝布里克什麼 – chell

相關問題