开发者

how can I set up the mail host so I can user one for production and one for development Rails

开发者 https://www.devze.com 2023-04-12 22:19 出处:网络
I have the following in my mailer: #activate board first using a different email? def welcome_manager(participant)

I have the following in my mailer:

#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

Which uses the host online. However when I am in development I want to use localhost:3000 as follows:

#activate board first using a different email?
def welcome_manage开发者_运维问答r(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

How can I do this?


You should setup your mail host in the respective config/environment/development.rb and production.rb.

However, if you really need to do it inline like that, just use a conditional on Rails.env:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号