【问题标题】:how to trouble shoot galleria.js in rails 3.x如何在 rails 3.x 中对 Galleria.js 进行故障排除
【发布时间】:2012-10-02 04:40:53
【问题描述】:

我正在将某人的 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

【问题讨论】:

    标签: javascript ruby-on-rails ruby galleria


    【解决方案1】:

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

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

    【讨论】:

    • 站点正在部署,但似乎没有加载插件。 sfmixology.herokuapp.com 想法?
    • 您是否将galleria JS 文件包含在您的application.js 清单文件中?
    • //= require_tree . 中的 application.js 不会覆盖这个吗?我添加了//= require galleria,但这并没有什么不同。
    • application.js 被添加到主文章中,你不是指 manifest.yml,我没有因为我没有在部署前预编译(正确吗?)
    猜你喜欢
    • 1970-01-01
    • 2011-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    相关资源
    最近更新 更多