Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails money-rails gem getting undefined method on monetize

I'm trying to get the money-rails gem working, and I'm having problems... >.<

Here's the product I have the appropriate columns on:

class ItemAttrVal < ActiveRecord::Base
  belongs_to :attr_name
  belongs_to :registry_item

  monetize :price_val_cents, :allow_nil => true
  #snip
end

I've run the migration, and the appropriate columns are there (price_val_cents, and price_val_currency).

I've got the gem in my Gemfile, and have run bundle install successfully.

When I do ItemAttrVal.new, I get this as the first line of the error message:

NoMethodError: undefined method `monetize' for #<Class:0x007fb489c759d0>

Could somebody help point out to me what simple thing I've missed? I haven't included it anywhere as a require (apart from my Gemfile), but I didn't think that was needed...

Thanks!

like image 377
Jty.tan Avatar asked Mar 02 '13 15:03

Jty.tan


1 Answers

Based on Peter Brown's comment, you should restart the console whenever a new gem is added, or when environment variable is added or modified. Just exit and start it again, rebooting the server is also recommended.

Sometimes the problem persists, even after restart. In that case try to kill the spring server so you are starting completely fresh.

like image 115
Lomefin Avatar answered Oct 17 '22 17:10

Lomefin