Dan Sketcher
2005-Jul-10 03:06 UTC
Mailer not resolving method from ApplicationHelper as of 0.13
Hi all, In my application I''ve got mailer template referencing a date formatting function that is from application_helper.rb. In 0.12.1 it was fine, but now I get this error: ActionView::TemplateError (undefined method `format_date_ddmmyyyy'' for #<ActionView::Base:0x36c06b0>) on line #3 of /payment_receipt.rhtml: Adding "require ''helpers/application_helper''" to the top of the mailer class didn''t help, and neither did "helper :application" in the mailer or controller that uses it (that one was a stretch, i know :) Does anyone know what''s going on? Cheers, Dan
Jamis Buck
2005-Jul-10 04:12 UTC
Re: Mailer not resolving method from ApplicationHelper as of 0.13
On Jul 9, 2005, at 9:06 PM, Dan Sketcher wrote:> Hi all, > > In my application I''ve got mailer template referencing a date > formatting function that is from application_helper.rb. In 0.12.1 it > was fine, but now I get this error: > > ActionView::TemplateError (undefined method `format_date_ddmmyyyy'' for > #<ActionView::Base:0x36c06b0>) on line #3 of /payment_receipt.rhtml: > > Adding "require ''helpers/application_helper''" to the top of the mailer > class didn''t help, and neither did "helper :application" in the mailer > or controller that uses it (that one was a stretch, i know :) > > Does anyone know what''s going on?Dan, as of 0.13, helpers are no longer shared amongst all controllers. Before, whether you needed a helper or not, if it was loaded by one controller, it was loaded by all controllers. This caused (among other things) namespace clashes and other ugliness. In 0.13, helpers are loaded into an anonymous module for each controller, so each controller only gets the helpers it needs (and requests). What is more, mailers do not use the application helper by default. However, you can explicitly add a helper to your mailers: class MyMailer < ActionMailer::Base helper :application_helper ... end Try that, and see if it helps. - Jamis
Chris Martin
2005-Jul-11 23:06 UTC
Re: Mailer not resolving method from ApplicationHelper as of 0.13
On 7/9/05, Jamis Buck <jamis-uHoyYlH2B+GakBO8gow8eQ@public.gmane.org> wrote:> On Jul 9, 2005, at 9:06 PM, Dan Sketcher wrote: > > ... Does anyone know what''s going on? > > Dan, as of 0.13, helpers are no longer shared amongst all > controllers. Before, whether you needed a helper or not, if it was > loaded by one controller, it was loaded by all controllers. This > caused (among other things) namespace clashes and other ugliness. > > In 0.13, helpers are loaded into an anonymous module for each > controller, so each controller only gets the helpers it needs (and > requests). What is more, mailers do not use the application helper by > default. However, you can explicitly add a helper to your mailers: > > class MyMailer < ActionMailer::Base > helper :application_helper > ... > end > > Try that, and see if it helps. > > - Jamis > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >Glad to find this email. I''ve been banging my head all morning trying to figure out what I broke! I could be mistaken, but I didn''t see anything about this in the CHANGELOG, or at http://weblog.rubyonrails.com/archives/2005/07/06/rails-013-225-featuresfixes-in-75-days/ Might be nice to add, at least in the changelog, to prevent other''s from bruising their forehead too. ;) -- Chris Martin Web Developer Open Source & Web Standards Advocate http://www.chriscodes.com/