【问题标题】:Rails 3.2/Active Admin - Custom asset pipeline path not working, resulting in ActionView::Template::Error (file.js isn't precompiled)Rails 3.2/Active Admin - 自定义资产管道路径不起作用,导致 ActionView::Template::Error(file.js 未预编译)
【发布时间】:2014-11-26 15:54:03
【问题描述】:

在我的 Rails 3.2 应用程序中,我使用 Active Admin 作为管理仪表板。我创建了一个自定义 javascript 文件以在我的一个表单上使用,并将其添加到 /initializers/active_admin.rb,如下所示:

config.register_javascript 'my_file.js'

由于 Active Admin 在/assets/active_admin 中查找此文件,但默认情况下该文件夹不直接可用,因此我创建了它并将my_file.js 放在那里。

我注意到,在将我的应用程序部署到 Staging 时,我无法查看 /admins 并在控制台中收到此错误:ActionView::Template::Error (my_file.js isn't precompiled)。因此,我在 SO 上进行了一些查看,发现了这个问题,并在 application.rb 中实现了海报的修复,如下所示:

module MyApp
  class Application < Rails::Application
  ...
  config.assets.paths << "#{Rails.root}/app/assets/active_admin"
  end
end

再次部署到 Staging 后,我仍然遇到同样的错误。谁能指出我在这里做错了什么?

【问题讨论】:

    标签: javascript ruby-on-rails ruby asset-pipeline activeadmin


    【解决方案1】:

    您可能应该将路径传递给文件,而不是目录,例如

    config.assets.precompile += ['my_file.js']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-08
      • 1970-01-01
      • 2012-06-19
      • 2012-07-20
      • 2013-07-14
      相关资源
      最近更新 更多