Forum: Ruby on Rails ActionMailer & application_helper.rb

Posted by Matt Stone (Guest)
on 2006-11-27 14:06
Hi,

I'm trying to send some emails with the same formatting as my pages & I
can't seem to access my display routines in application_helper.rb. I'm
trying a hack to bypass this.

At the top of my ActionMailer notifier script I've included
application_helper.rb - my understanding is that this should arrive as a
module and should be able to be used accordingly.

<% require File.dirname(__FILE__) +
'/../../helpers/application_helper.rb' %>
<% display_money = ApplicationHelper.display_money -%>

However I get a compile error:

undefined method `display_money' for ApplicationHelper:Module

The 'display_money' routine does exist in application_helper.rb & is
working happily when rendering my pages.

Any ideas on how I can overcome this?
Posted by Rob Nichols (reggieb)
on 2006-11-28 15:17
Matt Stone wrote:
> Hi,
> 
> I'm trying to send some emails with the same formatting as my pages & I
> can't seem to access my display routines in application_helper.rb. I'm
> trying a hack to bypass this.
> 
I think you can make the application helper available by adding:

helper :application

to the mailer model.
Posted by Matt Stone (Guest)
on 2006-11-28 16:32
Indeed you can - works great now.

Many thanks.

Rob Nichols wrote:
> Matt Stone wrote:
>> Hi,
>> 
>> I'm trying to send some emails with the same formatting as my pages & I
>> can't seem to access my display routines in application_helper.rb. I'm
>> trying a hack to bypass this.
>> 
> I think you can make the application helper available by adding:
> 
> helper :application
> 
> to the mailer model.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.