ryanb / letter_opener

Preview mail in the browser instead of sending.
MIT License
3.73k stars 237 forks source link

subject translations #87

Closed keilmillerjr closed 10 years ago

keilmillerjr commented 10 years ago

Any reason why this wouldn't work? Am I doing this correctly, or is it a bug? I'm trying to make my existing and working mailer to work with i18n translations.

# snippet from message_mailer.rb
mail to: ENV['MAILER_USERNAME'], subject: t('message_mailer.new_message', message: @message.name), css: ['mailers/message']
# snippet from en.yml
en
  message_mailer:
    new_message:
      subject: "New message from %{name}"

And the rendered mailer shows a subject like so:

Subject:
{:subject=>"New message from %{name}"}

EDIT: I changed the config from letter_opener to smtp, and this does not seem to be an issue with letter_opener. The actual emails to my inbox reflect the same results as letter_opener. Can anyone help me figure out what I am doing wrong anyways?

guilhermesimoes commented 10 years ago

Yes, this is unrelated to letter_opener.

t('message_mailer.new_message', message: @message.name)

should be

t('message_mailer.new_message.subject', name: @message.name)

Not sure if you already checked the Rails Guides, but this should be helpful.

nashby commented 10 years ago

@guilhermesimoes thanks!

keilmillerjr commented 10 years ago

Wow. I feel stupid, but really appreciate the help. Thank you very much!