Skip to content

Commit 4517977

Browse files
authored
Add warning for lambda default_currency for rails7
1 parent 93d2ee4 commit 4517977

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ MoneyRails.configure do |config|
276276
config.default_currency = -> { Tenant.current.default_currency }
277277
end
278278
```
279+
Be aware that this **does not work in Rails 7+**, as the lamda is evaluated immediately, and therefore requires your model to be loaded already.
280+
Workarounds include wrapping the initialization in `ActiveSupport::Reloader.to_prepare`, or creating a function that rescues unloaded constants with an initialization-time default, and running that in your lambda.
279281

280282
In many cases this is not enough, so there are some other options to
281283
meet your needs.

0 commit comments

Comments
 (0)