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

Rails 8: Cannot change default currency #709

Open
SylarRuby opened this issue Nov 30, 2024 · 0 comments
Open

Rails 8: Cannot change default currency #709

SylarRuby opened this issue Nov 30, 2024 · 0 comments

Comments

@SylarRuby
Copy link

SylarRuby commented Nov 30, 2024

In the latest rails 8.0, I could not seem to change the default currency from usd to gbp.

Things I've tried:

# initializers/money.rb

MoneyRails.configure do |config|
  config.default_currency = :gbp
  # config.default_currency = -> { :gbp }
end

Have also tried, in model:

# Meal.rb

register_currency :gbp # does nothing

# with_currency does nothing
monetize :price_cents, with_currency: :gbp

In rails console

Meal.last.price.currency.name #= "United States Dollar"

A workaround was to use a callback in the model:

[...]

after_initialize do |meal|
    self.price_currency = Money::Currency.new(:gbp)
   # If we kept register_currency :gbp, we could do:
   # self.price_currency = Meal.currency
end

Nothing actually works as per documentation. Has this issue been addressed, but not reflect on the documentation?

Thanks

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

1 participant