我有一个 mixin,我想将其包含在 Volt 应用程序的几个不同的类中。相关结构如下:
包括文件路径:app/component_1/models/my_model.rb
包含的文件路径:app/component_2/mixins/my_mixin.rb
这是我尝试过的:
require "#{Volt.root}/app/component_2/mixins/my_mixin"
加载页面时在服务器输出中产生此错误:SyntaxError: Cannot handle dynamic require
require "app/component_2/mixins/my_mixin"
启动服务器时产生此错误:in `require': cannot load such file
require_relative "../../component_2/mixins/my_mixin"
加载页面时在服务器输出中产生此错误:Opal::Builder::MissingRequire: A file required by "app.rb" wasn't found. can't find file: "../../component_2/mixins/my_mixin"
require "./app/component_2/mixins/my_mixin"
加载页面时在 javascript 控制台中产生此错误:Uncaught RuntimeError: no routes match path: /
不知道还有什么可以尝试的?