我遇到了一个奇怪的问题,我在将rails应用程序部署到生产环境时从未遇到过。
我跑:
bundle exec rake assets:precompile
这是输出:
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p0/bin/ruby /home/ubuntu/.rvm/gems/ruby-2.0.0-p0/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p0/bin/ruby /home/ubuntu/.rvm/gems/ruby-2.0.0-p0/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
这是我的app / assets / javascripts / application.js:
//= require jquery
//= require jquery_ujs
//= require jquery.ui.all
//= require twitter/bootstrap
//= require_tree .
这是我的app / assets / stylesheets / application.css:
/*
*= require_self
*= require jquery.ui.all
*= require_tree .
*/
我预编译后,这是我的公共/资产/应用程序-946a5a61f067fe19fe65ffd12f8c4a20.js
//= require jquery
//= require jquery_ujs
//= require jquery.ui.all
//= require twitter/bootstrap
//= require_tree .
所以它与原始文件完全相同。
public / assets / application-df7525e917401704ef453cb56bf16697.css是一个空文件。
这是我的Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'settingslogic'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'json'
gem 'will_paginate', '~>3.0.pre2'
gem 'friendly_id', '~> 4.0.0.beta14'
gem 'rails3-jquery-autocomplete'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'paperclip', '~> 3.0'
gem 'public_activity'
gem 'rails-timeago'
gem 'therubyracer', :require => 'v8'
gem 'less-rails'
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier', '>= 1.0.3'
end
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
和config / environments / production.rb:
Yupp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true
#config.assets.initialize_on_precompile = false
#...
end
任何方向都将受到高度赞赏。
答案 0 :(得分:3)
是什么解决了我的问题:
在Gemfile中设置最后一个rails版本(现在为3.2.14)
bundle update
bundle install
重新启动应用touch tmp/restart.txt
答案 1 :(得分:2)
我花了2个小时,然后找到了https://github.com/sstephenson/sprockets/issues/352
我尝试将ruby降级到1.9.3并进行预编译然后将编译后的文件添加到repo ..这不是我想要的但是它有效..
更新:您使用的是哪个rails版本?我正在使用3.2.2这样的问题。 3.2.13工作正常(使用ruby 2.0)。