# Money gem

**URL:** <https://www.ruby-forum.com/t/money-gem/69162>\
**Category:** Rails\
**Created:** [September 19, 2006, 2:19am UTC](https://www.ruby-forum.com/t/money-gem/69162 "2006-09-19T02:19:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [September 19, 2006, 2:19am UTC](https://www.ruby-forum.com/t/money-gem/69162/1 "2006-09-19T02:19:21Z")

</div>

Ok, I know I’m missing something obvious here, but I can’t spot it. I  
installed the money gem.

I’ve got this in my model:

composed\_of :unit\_price\_object, :class\_name =\> “Money”, :mapping =\> [  
%w(unit\_price, cents) ]

def formatted\_unit\_price  
self.unit\_price\_object.format(:html)  
end

def formatted\_unit\_price=(price)  
self.unit\_price\_object = Money.new(price)  
end

When I try to open a form with this line:

\<%= text\_field ‘product\_price[]’, ‘formatted\_unit\_price’, :size =\> 8  
%\>

I get this error:

uninitialized constant Money

Any thoughts?

Matt

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [September 19, 2006, 3:01am UTC](https://www.ruby-forum.com/t/money-gem/69162/2 "2006-09-19T03:01:28Z")

</div>

On 9/18/06 8:19 PM, “Matt R.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I get this error:
> 
> uninitialized constant Money
> 
> Any thoughts?
> 
> Matt

It might be a case issue with your include statement. Try an all  
lowercase:

require ‘money’

## ~ Mike

Work: [http://ClickableBliss.com](http://ClickableBliss.com)  
Play: [http://MikeZornek.com](http://MikeZornek.com)

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [September 19, 2006, 3:05am UTC](https://www.ruby-forum.com/t/money-gem/69162/3 "2006-09-19T03:05:29Z")

</div>

On 9/19/06, Matt R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> def formatted\_unit\_price  
> %\>
> 
> I get this error:
> 
> uninitialized constant Money
> 
> Any thoughts?
> 
> Matt

I haven’t used the Money gem before, but have you required it?

require ‘rubygems’  
require ‘money’

---

<div class="post-metadata">

**Author:** ![hazmatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@hazmatt](https://www.ruby-forum.com/u/hazmatt)\
**Post date:** [September 19, 2006, 3:19am UTC](https://www.ruby-forum.com/t/money-gem/69162/4 "2006-09-19T03:19:37Z")

</div>

Thanks Mike and Daniel -

I actually hadn’t required it. But now I get:

/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem\_original\_require’: no such file to load – Money

I tried it upper and lower case.

gem list gives me:

money (1.7.1)  
Class aiding in the handling of Money.

So it’s in there. What am I missing?
