Calling ActionView from uninheriting class

Hi Gurus, I have a class, specified in models cart.rb, which doesn’t
inherit from anything–it’s just a container

class Cart

I just discovered I can’t call number_to_currency in that class. Any
idea how to “include” it in my code? I tried
ActionView.number_to_currency without luck. I could kill a few lines
of non-DRY regexp code in cart.rb if I could just use
number_to_currency.

Many TIA,
Craig

Hi –

On Thu, 24 Sep 2009, Dudebot wrote:

of non-DRY regexp code in cart.rb if I could just use
number_to_currency.

That method is in the module ActionView::Helpers::NumberHelper, so you
can include that module (or extend an object with it or whatever).

David


David A. Black, Director
Ruby Power and Light, LLC (http://www.rubypal.com)
Ruby/Rails training, consulting, mentoring, code review
Book: The Well-Grounded Rubyist (http://www.manning.com/black2)

The easy way to resolve this type of problem is through: http//
api.rubyonrails.org
The Methods panel has, for your example, number_to_currency
(ActionView::Helpers::NumberHelper)

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