0

我正在将某人的 python 项目导入到 rails 并且在使 Galleria.js 画廊插件工作时遇到了一些麻烦。本地似乎一切正常,但当我部署到 heroku 时,网站根本无法加载,即“我们很抱歉,但出了点问题。” 该插件在本地正常工作。

我们将从 application.html.erb 中的 Galleria 加载标签开始

Galleria.loadTheme('<%= javascript_path('galleria.cinekine.js') %>');

我的 js 目录看起来像

javascripts/application.js`
javascripts/app.js.coffee`
javascripts/galleria.cinekine.js
javascripts/galleria.js

我的 .scss 看起来像

*
*= require_self
*/
@import 'bourbon';
@import 'meyer';
@import 'sfm';
@import 'apps';
@import 'galleria.cinekine';

我已经配置了 application.rb

config.assets.enabled = true

我相对确定 heroku 在预编译 Galleria.cinekine.js 文件时遇到问题,因为相关输出heroku logs

    eb.1]:   Rendered layouts/_footer.html.haml (1.5ms)
2012-10-02T04:36:05+00:00 app[web.1]: Completed 500 Internal Server Error in 106ms
2012-10-02T04:36:05+00:00 app[web.1]: 
2012-10-02T04:36:05+00:00 app[web.1]:   app/views/layouts/application.html.erb:18:in `_app_views_layouts_application_html_erb___1858155475977362126_43698200'
2012-10-02T04:36:05+00:00 app[web.1]: ActionView::Template::Error (galleria.cinekine.js isn't precompiled):
2012-10-02T04:36:05+00:00 app[web.1]: 
2012-10-02T04:36:05+00:00 app[web.1]:     21:   autoplay: 5000,
2012-10-02T04:36:05+00:00 app[web.1]:     15: <%= yield %>
2012-10-02T04:36:05+00:00 app[web.1]:     16: <%= render 'layouts/footer' %>

所有这些都非常有趣,因为当我推送它时,heroku 告诉我预编译在控制台中是可以的。

想法?一如既往,StackFoo 非常感谢。

application.js 的内容

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require galleria
4

1 回答 1

1

您的所有 JS 都被预编译到一个文件中,大概是application.js,因此您不能在页面上包含 JS 文件的非预编译版本,除非您将其添加到config/environments/production.rb

config.assets.precompile += %w( galleria.cinekine.js )
于 2012-10-02T04:52:47.930 回答