【问题标题】:Coffeescript Not Updating in Heroku咖啡脚本没有在 Heroku 中更新
【发布时间】:2016-06-27 09:05:38
【问题描述】:

所以,我对托管在 Heroku 上的网络应用程序进行了一些更改,然后我照常进行

git add .
git commit -m
git push
git push heroku

这些命令中的任何一个都没有错误...但是当我检查网站时,似乎所有更改都已推送,除了我的 Coffeescript 文件中的更改。而当我查看网页的源代码时,我看到的是旧的JS代码......就像它跳过了coffeescript文件中的更改一样。 推送中没有错误,并且当我提交时咖啡脚本文件在文件列表中。

这是我迄今为止尝试过的:

  1. 添加到我的 gemfile

    gem 'therubyracer'

  2. 添加到 Production.rb: config.assets.compile = true config.assets.initialize_on_precompile = true

  3. 重启 Heroku 服务器

  4. 删除了我的浏览器数据...

这些都不起作用。请有人帮助或指出正确的方向。

这是我的 Gemfile:

source 'https://rubygems.org'
ruby "2.2.1"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sprockets-rails'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'gon'
group :development, :test do
gem 'byebug'
end

group :development do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
gem 'web-console', '~> 2.0'
gem 'spring'
end

group :production do
gem 'pg',             '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'puma',           '2.11.1'
gem 'therubyracer'
end

这是 production.rb 文件:

Rails.application.configure do
  config.cache_classes = true

  config.eager_load = true

  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

  config.assets.js_compressor = :uglifier

  config.assets.compile = true
  config.assets.initialize_on_precompile = true
  config.assets.digest = true
  config.log_level = :debug
  config.i18n.fallbacks = true

  config.active_support.deprecation = :notify

  config.log_formatter = ::Logger::Formatter.new
  config.active_record.dump_schema_after_migration = false
end

谢谢!

【问题讨论】:

    标签: ruby-on-rails ruby heroku coffeescript


    【解决方案1】:

    您的 js 或 css 中可能存在错误,导致您的资产无法编译。尝试通过运行在本地编译:

    rake assets:precompile
    

    然后在重新部署之前再次添加并提交。

    【讨论】:

    • 是的...只需要再等 4 分钟 :)
    猜你喜欢
    • 2015-01-28
    • 1970-01-01
    • 2014-04-06
    • 2011-09-15
    • 1970-01-01
    • 2021-05-03
    • 2013-01-09
    • 1970-01-01
    • 2011-11-14
    相关资源
    最近更新 更多