Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set currency to :eur #3

Open
francisneedham opened this issue Aug 5, 2016 · 4 comments
Open

Cannot set currency to :eur #3

francisneedham opened this issue Aug 5, 2016 · 4 comments

Comments

@francisneedham
Copy link

Hi,
I'm using the GEM on a rails 5 project.
Everything is working perfectly but i cannot change the currency to eur.

i have in my MoneyRails initializer
config.default_currency = :eur

but still does not work.

Thanks !

Francis

@dirceuvjr
Copy link

Seems like this gem doesn't have support for any currencies other than USD.
If you set another currency in the money initializer, it will fail.

@dabit
Copy link
Owner

dabit commented Aug 10, 2016

@francisneedham acts_as_shopping_cart doesn't mess with the default currency at all and by changing things around on functional test it seems to work.

Maybe there's something wrong at the Rails initializer level?

@Dee-2015
Copy link
Contributor

@francisneedham Does the object you are adding to the cart have 'monetize :price_cents' macro enabled?

@acapro
Copy link

acapro commented Jan 15, 2019

having a look at acts_as_shopping_cart/lib/acts_as_shopping_cart/schema.rb if you use the shopping_cart_item_fields method, it will create a price_currency with a default of 'USD'. I would recommend installing the latest version of rails-money and using their add_monetize :products, :price # Rails 4x and above method for the migration.

A migration similar to this would allow for the default currency to work:

class CreateShoppingCarts < ActiveRecord::Migration[5.2]
  def change
    create_table :shopping_carts do |t|
      t.timestamps
    end

    create_table :shopping_cart_items do |t|
      t.integer  :owner_id
      t.string   :owner_type
      t.integer  :quantity
      t.integer  :item_id
      t.string   :item_type
      t.monetize :price

      t.timestamps
    end
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants