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'
Fixed it by doing this in main/config/initializers
:
if RUBY_PLATFORM == 'opal'
require_relative 'client/my_file'
else
end