jQuery / Javascript在本地运行,但不在Heroku上运行

时间:2013-12-13 20:40:27

标签: javascript jquery ruby-on-rails heroku

这是我在Heroku上的应用程序:http://mighty-brushlands-6367.herokuapp.com/这就是它应该看起来的样子,就像在本地一样:

enter image description here

我做了一些谷歌搜索。我检查了这个解决方案:JQuery events are not working on heroku in production but work in development和其他人。

我继续跑heroku run rake assets:precompile,但仍无法在Heroku上获得效果。这就是我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
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require bootstrap
//= require textEffect

我需要一些指导。我是一个渴望知识的新手。

2 个答案:

答案 0 :(得分:0)

您的Heroku应用程序在application.js&上遇到404错误application.css文件让我相信它首先没有被推到Heroku。

尝试在开发中运行rake assets:precompile,然后执行常规步骤git add .,然后git commit,然后git push

答案 1 :(得分:0)

解决方案是添加

group :production, :staging do
  gem 'rails_12factor'
end

到Gemfile并再次提交到Heroku