Reputation: 1314
I would like to include the following code in the subject line for my rails mailer but cannot get it to work..What is the proper syntax for this? Thanks!
<%= @occasions.map{|o|o.pname+"'s "+o.name}.to_sentence %>
Mailer:
def upcoming_deals_mail(user)
@user = user
@occasions = user.upcoming_occasions_with_deals
@deals = user.upcoming_deals
@subject = "An friendly Reminder"
mail(:to => "#{ user.email } <#{ user.email }>", :subject => @subject)
end
Upvotes: 2
Views: 563
Reputation: 61
Adding double quotes (" ") instead of single (' ') did it for me
Fail:
mail(to: '[email protected]', subject: 'Application for: #{@applicant.full_name}')
Success:
mail(to: '[email protected]', subject: "Application for: #{@applicant.full_name}")
Upvotes: 3
Reputation: 15788
I am not sure I understood you well but if all you want to do is including the specified ruby expression in your mail subject you can replace @subject = "An friendly Reminder"
with
@subject = @occasions.map{|o|o.pname+"'s "+o.name}.to_sentence
Upvotes: 0