0

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_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

How can I do this?

chell
  • 7,646
  • 16
  • 74
  • 140

1 Answers1

0

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"
bricker
  • 8,911
  • 2
  • 44
  • 54