0

I'm writing an app that requires me to define a Ruby class outside of the controller, and then instantiate it within a controller.

I put it in lib/my_file.rb and also initializers/client/my_file.rb and got the same result:

Sprockets::FileNotFound at / couldn't find file 'client/my_file' with type 'application/javascript'

Rick
  • 8,366
  • 8
  • 47
  • 76

1 Answers1

1

Fixed it by doing this in main/config/initializers:

if RUBY_PLATFORM == 'opal' require_relative 'client/my_file' else end

Rick
  • 8,366
  • 8
  • 47
  • 76