Forum: Ruby on Rails How to include the mail_to helper inside of a controller

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B5378bc51d0a3c94c1c5ba13181ec091?d=identicon&s=25 Inverted (Guest)
on 2011-03-01 20:53
(Received via mailing list)
Hello, in my controller I need to format a json object using
simple_format, which is why I need to include several helpers.

So far I have the following in my controller:

      include ApplicationHelper
      include ActionView::Helpers::TextHelper
      include ActionView::Helpers::TagHelper

This works great for simple_format, problem is when the
comment.content has a email address, rails trys to do a mailto link
which breaks, showing the following error in the logs: "NoMethodError
(undefined method `mail_to' for...."

Any ideas on how to add it in? I tried adding   include
ActionView::Helpers::UrlHelper but that did not work. I get this error
when I include the UrlHelper: "undefined local variable or method

Thank you
56b7e1808013614acdb73cbaaa6938a1?d=identicon&s=25 Michael Pavling (Guest)
on 2011-03-01 22:42
(Received via mailing list)
On 1 March 2011 18:41, Inverted <> wrote:
> Hello, in my controller I need to format a json object using
> simple_format, which is why I need to include several helpers.
> Any ideas on how to add it in?

Coincidentally, I had to resort to using number_to_currency in a
controller the other day (okay, I didn't *have* to - I decided it
easier to do it that way for the task I had to do :-)

A quick Google for "number_to_currency controller" (now I'm giving
away my Google-fu?!) gleaned this:

..and for my quick and "I feel dirty" use, I settled for the solution:

B5378bc51d0a3c94c1c5ba13181ec091?d=identicon&s=25 Inverted (Guest)
on 2011-03-01 23:30
(Received via mailing list)
Pavling, thanks for the repy! I've been stuck on this bug all morning...

So I'm trying to understand how to get this working based on your

Here's the flow:

My controller calls html_format(comment.content) which is inside of the
application helper

html_format, then calls simple_format. This only errors when there is an
email in comment.content. If there is a link or just plain text it works
just fine.

Given that, can you help me understand your suggestion on how to
Thank you!
B5378bc51d0a3c94c1c5ba13181ec091?d=identicon&s=25 Inverted (Guest)
on 2011-03-01 23:43
(Received via mailing list)
Ok turns out it's not simple_format, I forgot that I was using
Removing auto_link prevent the error. So now I need to figure out what I
need to include in the controller to user auto_link
This topic is locked and can not be replied to.