更新到Rails 4后资产预编译的问题

时间:2013-03-25 02:25:46

标签: ruby-on-rails sprockets

我正在将Rails应用程序从3.2.12更新到4.0.0.beta1。我有一些小问题,但我可以让应用程序运行,所有测试再次通过。问题是当我尝试预编译所有资产以进行部署时,我收到以下错误:

vagrant@precise64:/vagrant$ RAILS_ENV=production bundle exec rake assets:precompile
rake aborted!
No such file to load -- bootstrap_flash_helper
/vagrant/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace)

这是我的Gemfile:

source 'https://rubygems.org'

gem 'rails', '4.0.0.beta1'

gem 'pg'
gem 'github_api'
gem 'haml-rails'
gem 'jquery-rails'
gem 'simple_form', github: 'plataformatec/simple_form'
gem 'devise', github: 'plataformatec/devise', branch: 'rails4'
gem 'omniauth'
gem 'omniauth-github'
gem 'rails-backbone', '~> 0.9.10'
gem 'inherited_resources'
gem 'app_configuration'
gem 'unicorn'
gem 'foreman'
gem 'coveralls', require: false

group :assets do
  gem 'sprockets-rails',  github: 'rails/sprockets-rails'
  gem 'coffee-rails',     github: 'rails/coffee-rails'
  gem 'therubyracer',     platforms: :ruby
  gem 'less-rails',       github: 'metaskills/less-rails'
  gem 'twitter-bootstrap-rails'
  gem 'uglifier', '>= 1.0.3'
end

group :development do
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'meta_request'
end

group :test, :development do
  # Debugging
  gem 'pry'
  gem 'debugger'
  gem 'debugger-pry'
  gem 'pry-nav'
  gem 'pry-stack_explorer'

  # Testing
  gem 'timecop'
  gem 'rspec-rails'
  gem 'shoulda-matchers'
  gem 'factory_girl_rails'
  gem 'faker'
  # gem 'cucumber-rails', '~>1.3.0', :require => false
  gem 'database_cleaner', github: 'bmabey/database_cleaner'
end

该项目是开源的(正在进行中),这里是github存储库https://github.com/wolox/mgmt

关于我遗失的任何想法?

由于

2 个答案:

答案 0 :(得分:1)

我遇到了类似的问题,然后我发现 group:assets 不再存在了。克隆你的仓库后,我从你的Gemfile中删除了 组:assets ,然后你的资产预编译好了!

答案 1 :(得分:0)

默认情况下,资产组未在生产环境中加载,您可以在config / application.rb(您的回购中https://github.com/Wolox/mgmt/blob/master/config/application.rb#L7)中更改此内容

建议的做法是在开发中编译资产,然后在满意的情况下将/ public / assets目录推送到生产环境。

请改用此行,您应该没问题:

RAILS_ENV=development bundle exec rake assets:precompile