RubyMoney/money-rails

uninitialized constant MoneyRails::ActionViewExtension after upgrading to Rails 6.1

atstockland opened this issue · 8 comments

I call "include MoneyRails::ActionViewExtension" in a couple helpers and Prawn pdf documents so I can use humanized_money_with_symbol and other money methods. This has worked as expected for years...until today.

Upon upgrading to Rails 6.1, I now get the following error:

  NameError - uninitialized constant MoneyRails::ActionViewExtension

I'm assuming this is the result of a structural change in Rails 6.1. I am still figuring out this change, and others....but, thought this was worthy of submitting.

Sorry I don't have more to offer by way of details or solutions...but, I'm not sure how these pieces all work together.

A good place to start would be to add a new spec target for Rails 6.1 and make sure the error is exposed. I'll have a look at it when I get some spare time, but feel free to start working on this, contributions are always very welcome

I'm not sure what the cause is, but I had the same problem.

I was able to work around it by putting this at the top of my config/initializers/money.rb (before the configure block):

money_gem_dir = Gem::Specification.find_by_name("money-rails").gem_dir
require "#{money_gem_dir}/lib/money-rails/helpers/action_view_extension"

@mark100net dude, thanks, that worked for me 💪 👊

@mark100net care to submit a PR or shall we close this?

@semmons99 I am no longer using this gem. I did just take a look with a clean Rails 6.1.3 app and version 1.13.3 of the gem and was not able to reproduce it. I'm not 100% sure if that means it's fixed or just that I did something different.

In any case it is probably more up to @atstockland as to whether to close since it is his issue.

I’ll close it. I changed my code to not rely on what caused the issue for me in the first place. I’ll give @mark100net ’s solution a try.

I'm not sure what the cause is, but I had the same problem.

I was able to work around it by putting this at the top of my config/initializers/money.rb (before the configure block):

money_gem_dir = Gem::Specification.find_by_name("money-rails").gem_dir
require "#{money_gem_dir}/lib/money-rails/helpers/action_view_extension"

@mark100net It worked for me.. Thanks Much!