badnaam
badnaam

Reputation: 1884

render partials in actionmailer templates

I am trying to use an existing partial in an actionmailer template, something like..

My merchant_offer.txt.html.erb

<%= render :partial => "offers/offer", :locals => {:offer => @offer} %>

Notifier.rb (my mailer class):

def merchant_offer(offer)
    subject "New Offer from #{offer.merchant.name}"
    from "[email protected]"
    recipients xxx@
    sent_on Time.now
    body :offer => offer
end

The offer partial in in another view folder called offers

But it throws a missing tempalate error.

Is there a way to re-use existing view partial in in mailer tempalates?

Thanks

Upvotes: 5

Views: 4049

Answers (1)

nvunguyen
nvunguyen

Reputation: 223

You should be able to render partial from mailer templates.

I believe the error is in your merchant_offer view. Try renaming 'merchant_offer.txt.html.erb' to 'merchant_offer.html.erb'

Upvotes: 5

Related Questions