我无法使用命令预编译 - > bundle exec rake assets:precompile
,它让我回复了这个错误 - > Don't know how to build task 'assets:precompile'.
在预编译之前,我做了bundle install --deployment --without development test
Rails 3.0.11
Ruby 1.9.2p320(2012-04-20 revision 35421)[x86_64-linux]
答案 0 :(得分:0)
您说您使用捆绑安装进行预编译,这不会预编译资产,只是安装您的宝石,如果您想要将更新的宝石安装到rails服务器,只需再次运行bundle install
或bundle update
。 rails 3.0没有资产管道。
如果您确实想要使用资产管道,请参阅文档:
this backport在你的Gemfile中:
gem "sprockets_rails3_backport"
...plus whatever supplementary gems you want for the asset pipeline:
gem 'coffee-script', '2.2.0'
gem 'therubyracer', '0.9.9'
gem 'uglifier', '>= 1.0.3'
在您的routes.rb中:
MyApp::Application.routes.draw do
if (app = Rails.application).config.assets.compile
mount app.assets => app.config.assets.prefix
end
# ...
end
以下是各种config.assets选项及其默认值:
config.assets.paths = []
config.assets.precompile = [ Proc.new{ |path| !['.js', '.css'].include?(File.extname(path)) },
/(?:\/|\\|\A)application\.(css|js)$/ ]
config.assets.prefix = "/assets"
config.assets.version = ''
config.assets.debug = false
config.assets.compile = true
config.assets.digest = false
config.assets.manifest = nil
config.assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ]
config.assets.js_compressor = nil
config.assets.css_compressor = nil
config.assets.initialize_on_precompile = true