【问题标题】:jQuery/Javascript runs on local but not on HerokujQuery/Javascript 在本地运行,但不在 Heroku 上
【发布时间】:2013-12-13 20:40:27
【问题描述】:

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

好吧,我做了一些谷歌搜索。我检查了这个解决方案: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

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

【问题讨论】:

    标签: javascript jquery ruby-on-rails heroku


    【解决方案1】:

    您的 Heroku 应用在 application.js 和 application.css 文件上出现 404 错误,这让我相信它一开始没有被推送到 Heroku。

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

    【讨论】:

      【解决方案2】:

      解决方案是添加

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

      到 Gemfile 并再次提交到 Heroku

      【讨论】:

        猜你喜欢
        • 2013-09-22
        • 2015-10-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-07-04
        • 2015-02-07
        • 2021-08-25
        相关资源
        最近更新 更多