2013-11-27 93 views
1

这让我疯狂!我的应用在本地服务器上正常工作,但是当我上传到heroku时,css和js文件没有更新。我阅读使用rake资源进行预编译:预编译修复问题,但之后我再次上传到heroku,现在我的所有资源都没有加载!我已经尝试了所有的预编译变体,安装了12factor gem,将一些配置设置从false变为true,但仍然没有发生!当我看到控制台,它说'rake assets:precompile'之后Rails 4资产没有加载到heroku中

[错误]的ReferenceError:找不到变量:jQuery的 全局代码(应用38ccb09605964287831a37a0d9faf188.js,1号线)

,但我有jQuery的!它在当地正常工作!我不知道我在做错什么。

的Gemfile

gem 'bootstrap-sass-rails' 
gem 'rails_12factor', group: :production 

gem 'rails', '4.0.0' 

gem 'sqlite3', :group => [:development, :test] 
group :production do 
    gem 'thin' 
    gem 'pg' 
end 

gem 'sass-rails', '~> 4.0.0' 

gem 'uglifier', '>= 1.3.0' 

gem 'coffee-rails', '~> 4.0.0' 

gem 'jquery-rails' 

gem 'jbuilder', '~> 1.2' 

group :doc do 
    # bundle exec rake doc:rails generates the API under doc/api. 
    gem 'sdoc', require: false 
end 

production.rb

config.cache_classes = true 
config.eager_load = true 
config.consider_all_requests_local = false 
config.action_controller.perform_caching = true 
config.serve_static_assets = true 
config.assets.js_compressor = :uglifier 
config.assets.compile = true 
config.assets.digest = true 
config.assets.version = '1.0' 
config.log_level = :info 
config.i18n.fallbacks = true 
config.active_support.deprecation = :notify 
config.log_formatter = ::Logger::Formatter.new 
+0

,可以在运行'Heroku的logs'并显示其内容? – Thanh

+0

它的种类很长,所以我把它放在谷歌文档里面。 https://docs.google.com/document/d/13ymjsdT2fvamFmGvKvsir582u4dcNL27-1qxWZpoV6g/编辑 – user2968401

+0

好的..我今天早上登录了,现在我的本地应用程序现在不工作了..要么已经被缓存了什么。 – user2968401

回答

3

运行$RAILS_ENV=production bundle exec rake assets:precompile现在我的Heroku应用程序的工作。所以我想的问题是固定的..

对不起,我没有,为什么它的工作原理

+0

谢谢!这是一个非常令人沮丧的问题,这解决了它!谁会想到只是在本地预编译资产并推送到Heroku就行。 – Magne

0

的解释只需运行

$ bundle exec rake assets:precompile 
    $ git add . 
    $ git commit -am "assets precompiled locally" 
    $ git push heroku master 
+0

第一次运行命令之前首先运行“rake assets:clean” – Chris

相关问题