在 Volt 框架中需要文件

Requiring files in the Volt Framework

我有一个 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: /

不确定还可以尝试什么?

抱歉,这还不清楚,我会尝试更新文档以使其更容易。所以应用程序文件夹是加载路径上的内容。所以你可以从那里要求。

需要'component_2/mixings/my_mixin'