Money gem

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

On 9/18/06 8:19 PM, “Matt R.” [email protected]
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
Play: http://MikeZornek.com

On 9/19/06, Matt R. [email protected] 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’

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?