Cannot use view helpers in RJS helpers

Any ideas why I would get an error in a RJS helper on view helpers
such as number_to_currency.

Example:

my_template.rjs

page.help_me

my_helper for my_controller

def help_me
number_to_currency(10)
end

I have also tired page.number_to_currency but that doesn’t work either.

Cheers,
Nicholas

It has to do with the scope of the helper. The ActionView::Helpers
modules aren’t included into the context the RJS helper method is
executed in. You can manually include the helpers you want into your
module like so:

module ExpensesHelper
include ActionView::Helpers::NumberHelper

def help_me
number_to_currency(10)
end
end

On 4/8/06, Nicholas H. [email protected] wrote:

Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Cody F.
http://www.codyfauser.com

Brilliant! Thanks :slight_smile: