# Calling ActionView from uninheriting class

**URL:** <https://www.ruby-forum.com/t/calling-actionview-from-uninheriting-class/176102>\
**Category:** Rails\
**Created:** [September 24, 2009, 9:18pm UTC](https://www.ruby-forum.com/t/calling-actionview-from-uninheriting-class/176102 "2009-09-24T21:18:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [September 24, 2009, 9:18pm UTC](https://www.ruby-forum.com/t/calling-actionview-from-uninheriting-class/176102/1 "2009-09-24T21:18:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [September 24, 2009, 9:26pm UTC](https://www.ruby-forum.com/t/calling-actionview-from-uninheriting-class/176102/2 "2009-09-24T21:26:05Z")

</div>

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](http://www.rubypal.com))  
Ruby/Rails training, consulting, mentoring, code review  
Book: The Well-Grounded Rubyist ([The Well-Grounded Rubyist](http://www.manning.com/black2))

---

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [September 26, 2009, 1:36pm UTC](https://www.ruby-forum.com/t/calling-actionview-from-uninheriting-class/176102/3 "2009-09-26T13:36:47Z")

</div>

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