Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一个应用程序,它需要我在控制器之外定义一个 Ruby 类,然后在控制器中实例化它。
我把它放进去lib/my_file.rb,也initializers/client/my_file.rb得到了同样的结果:
lib/my_file.rb
initializers/client/my_file.rb
Sprockets::FileNotFound at / couldn't find file 'client/my_file' with type 'application/javascript'
通过这样做修复它main/config/initializers:
main/config/initializers
if RUBY_PLATFORM == 'opal' require_relative 'client/my_file' else end