如何在 Rails 3.x 中对 Galleria.js 进行故障排除



我正在将某人的 Python 项目导入 Rails 并在让 Galleria.js 画廊插件工作时遇到一些麻烦。 在本地一切似乎都很好,但是当我部署到 heroku 时,该网站根本不会加载,即"很抱歉,出了点问题。 该插件在本地正常工作。

我们将从 Galleria 负载标签开始,在 application.html.erb

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';

我配置了应用程序.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非常感谢。

申请内容.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

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

config.assets.precompile += %w( galleria.cinekine.js )

最新更新