Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Michael McLaughlin
Michael McLaughlin
14,033 Points

Money Issues

hi, so I am getting an error thown when I use the Money library that is first introduced in the currency video in ruby development. The first thing that happened was, after I used the command: gem install money, only one gem was installed instead of 3 which is shown in the video.

Later, when I started using the library, I saw when I typed the following command:

money = Money.new(1000)

this message was printed:

#<Money fractional:1000 currency:USD> 

this is different from the one received in the video, since it is:

#<Money cents:1000 currency:USD> 

when I tried to print out the variable that the money library was being used for, I ran into this error:

puts money
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.

I would just like to know if anyone knows if this is a bad thing, if I have to install the missing gems, or what is going on in general. I am on a mac osx 10.8.5 and I have 1.9.3-p484 installed for ruby.


ok, so the last error has gone away, but I guess I would like to know why there was only 1 gem installed and why mine says fractional.

It may say that only one gem was installed because the other ones may have already been installed. I can't help much because I don't seem to know which video you're referring to?

1 Answer

require 'money'
m = Money.new(1000)
 # => #<Money fractional:1000 currency:USD>

The fact that it only shows the two instance variables, which you can check for like...

 # => [:@fractional, :@currency, :@bank]

...doesn't matter because cents is a method (as m.methods.include? :cents is true). And when you do this...

 # => 1000

...you get the value you saw. This may be because we are using a newer version of the money gem and the functionality may have changed.