Using link_to and mail_to helpers with Activemailer

Hi, everyone.

I’ve been looking at sending out emails recently from my app and seem to
be getting some frustrating behaviour from a partial that I use to
construct the email views. Using HTML emails rather than plaintext.

The email view renders a standard _mail_footer.rhtml partial that I’ve
created.

In application_helper, I have two helpers that return the site URL in
different formats:

def site_url
  "www.example.com"
end

def dotcom_name
  "example.com"
end

I then use this in mail_footer:

<%= link_to "FAQ", "http://#{site_url}/main/faq" %>

At this point, the site_url helper works without a problem. The link is
correctly created in the emails that arrive.

But I then try using the mail_to helper to construct a mailto link in
the email, this time using dotcom_name:

<%= mail_to("[email protected]#{dotcom_name}" , "[email protected]#{dotcom_name}" ,
   :subject => "Question from #{@user.name}" ,
   :encode => "javascript" ) %>

In the emails that arrive, the mailto seems to be missing completely.

Could someone please point out to me what incredibly obvious thing I’m
doing wrong? I’ve had a search through the posts here, but can’t yet
find the solution.

Thank you for your time,

Dave

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs