繁体   English   中英

Rails:Javascript没有进入heroku

[英]Rails: Javascript not getting to heroku

即使我的application.html.haml文件包含: = javascript_include_tag "application"我的javascript也没有进入我的heroku应用= javascript_include_tag "application" 我发出警报,检查是否有任何js在那里,但没有雪茄。 我还检查了firebug并且javascript没有被发送到浏览器那么多。 有任何想法吗?

的application.js

//= require jquery
//= require jquery_ujs
//= require_tree .
//= require jquery_nested_form
//= require jquery-fileupload
//= require autoNumeric
//= require lightbox

alert('test?');

Production.rb

MyMyApp::Application.configure do
  config.force_ssl = true
  config.cache_classes = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = true (I tried false)
  config.assets.compress = true
  config.assets.compile = true
  config.assets.digest = true
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
end

红宝石'2.0.0'

宝石'轨道','3.2.13'

资产管道和heroku存在许多问题。 检查这个linke

https://devcenter.heroku.com/articles/rails-asset-pipeline

或者简单地放入config / application.rb行:

config.assets.initialize_on_precompile = false

这应该可以解决你的问题。

2件事:

- >尝试在文档准备好时调用

$(document).ready(function() {
    alert('hello');
});

- >在推送到Heroku之前尝试预编译资产:

在你的production.rb中:

config.serve_static_assets = true
config.assets.compile = true

在您的cmd中:

> rake assets:precompile
> git push heroku master

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM