Using a money_column gem with rails

I'm noob rails ... using Rails 3.1

I am trying to use the money_column gem . I installed the gem added to my gemfile, install the package. I installed a product model, for example, an example.

My product model:

class Product < ActiveRecord::Base belongs_to :product_category attr_accessible :sku, :name, :description, :price, :available, :product_category_id money_column :price end 

I created some seed data in seeds.rb. However, when I run rake db: seed, I get an error message:

 rake aborted! undefined method `money_column' for #<Class:0x007fccbd26e468> 

Am I missing something while setting money_column?

+4
source share
1 answer

I looked at the source code of this gem, and I think it will work if you change your model to this:

 require 'money' require 'money_column' class Product < ActiveRecord::Base include MoneyColumn belongs_to :product_category attr_accessible :sku, :name, :description, :price, :available, :product_category_id money_column :price end 

Also, are you sure you are using the right stone? official money_column gem at rubygems.org : https://github.com/chargify/money_column

+2
source

Source: https://habr.com/ru/post/1384608/


All Articles