0

I'm having some differing behavior in my development and staging app. The same action that works locally gets this on staging (production env)

#<NameError: uninitialized constant #<Class:0x0000557d7c986aa8>::Report>
/app/app/models/cart.rb:26:in `add_product'
/app/app/controllers/cart_controller.rb:10:in `add_remove'
/app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.2.0/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'

I don't really understand what is going on here. Perhaps a different RUBY_VERSION is loaded in the console on staging?

In my Gemfile I have:

ruby '2.3.6'

UPDATE:

I've gone back and checked my local logs, and see that the errors there also show ruby 2.3.0:

/Users/myuser/.gem/ruby/2.3.0/gems/actionpack-5.2.0/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'

I'm clearly misunderstanding something. What am missing? Are gems always run from the lowest patch version of ruby?

pixelearth
  • 13,674
  • 10
  • 62
  • 110
  • I think your efforts are misdirected. I'd trust `RUBY_VERSION` and take a closer look at the code that raises the error. A few patchlevel versions are extremely unlikely to change the way ruby loads/resolves constants. – Sergio Tulentsev May 25 '18 at 12:37
  • I have voted to reopen since you change this completely but that being said please post the code that actually causes the error – engineersmnky May 25 '18 at 17:35

1 Answers1

1

The folder ruby is installed on doesn't match the patch version. Only the minor.

The value RUBY_VERSION is the one you can trust.

Damien MATHIEU
  • 31,924
  • 13
  • 86
  • 94
  • Ok, I realize I've made this post about the first idea that came to mind for solving my actual problem, which is the differing behavior between local and staging (::Report>). If it's not the ruby version, then something else is going on. Ideas? – pixelearth May 25 '18 at 12:40
  • @pixelearth: check `eager_load`, `cache_classes` or other settings like that. – Sergio Tulentsev May 25 '18 at 12:41
  • @SergioTulentsev The problem is probably something like that, but I can't find it. The app is an upgrade from rails 4.2. I've gone through all of the minor versions until 5.2. I looked in my config/environments/production.rb and no setting has changed (I did the app:update process) regarding eager_loading and cacheing. Here's the file. https://gist.github.com/benlieb/16cdfb65e773171b0ec718ddd1d8876c – pixelearth May 25 '18 at 12:52