Coffeescript未在Heroku中更新

Igg*_*ggy 3 ruby ruby-on-rails heroku coffeescript

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

git add .
git commit -m
git push
git push heroku
Run Code Online (Sandbox Code Playgroud)

在任何这些命令中没有错误......但是当我检查网站时,似乎除了我的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
Run Code Online (Sandbox Code Playgroud)

这是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
Run Code Online (Sandbox Code Playgroud)

谢谢!

tod*_*eny 6

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

rake assets:precompile
Run Code Online (Sandbox Code Playgroud)

然后在重新部署之前再次添加和提交.

  • 哦,它有效.非常感谢! (2认同)