In my Rails app, I use a method in my Mailer views for creating a link that takes a format param based on whether it's in html
or text
format.
mailer_link_to( url, link_text, format )
Depending on the format, it either creates an anchor <a>
tag for html or just shows the url
for text.
So for each Mailer method, I have two views:
myemail.html.erb
myemail.text.erb
In myemail.html.erb
, I use mailer_link_to( "http://ntwrkapp.com", "ntwrk", "html" )
.
In myemail.text.erb
I use mailer_link_to( "http://ntwrkapp.com", "ntwrk", "text" )
.
What I'm wondering is if I can determine what the format is so I'm not having to duplicate myself so much and specify "html"
or "text"
each time.
If I was in a normal view/controller, I would do something like request.format
but the request
object isn't available in the Mailer views.
Thanks!
Aucun commentaire:
Enregistrer un commentaire