私たちのアプリはRails 2からRails 3.1にアップグレードされており、アセットパイプラインに問題があります。Rails 3.1のアセットパイプラインにファイルが表示されない
私は私のconfig/application.rbに次のように持って:development.rb
# Do not compress assets
config.assets.compress = false
config.assets.debug = true
で
if defined?(Bundler)
Bundler.require *Rails.groups(:assets => %w(development test))
# Bundler.require(:default, :assets, Rails.env)
end
# Enable the asset pipeline
config.assets.enabled = true
# config.assets.prefix = "/assets"
config.assets.paths << "#{Rails.root}/public/images"
config.assets.paths << "#{Rails.root}/public/stylesheets"
config.assets.paths << "#{Rails.root}/public/javascripts"
config.assets.version = '1.0'
そして、この私は、これがために所望の動作ではありません知っていますこの方法でアップグレードをマージブランチにマージすると、すべての古いファイルが適切に処理されるようにしています。
Iその後、私のパブリック/スタイルシートのディレクトリに、 "all.css、" 次のファイルがあります。
/*
*= require ezform
*= require jquery-ui-1.8.9.custom
*= require thickbox
*= require yui-upload
*= require styles
*/
私はそうのように私のレイアウト内/ application.html.erbファイルからそれを呼び出しています:
<%= stylesheet_link_tag "all" %>
しかし、ブラウザに読み込んでも、私はスタイル(またはjavascriptなど)を得られません。 FirebugとChromeは、.cssファイルと.jsファイルが "/ assets"で検索されていると伝えています。パイプラインはすべてを検索していないようにバンドルしているようです。
エラーは次のようになります。
GET http://localhost:3000/assets/jquery-dependent.js 500 (Internal Server Error)
私は/アプリ/資産に「all.css」を移動した場合、それはまだそれを見つけることができません。それを/ assetsに移動するとエラーは止まりますが、スタイルシートはコンパイルされず、ブラウザにはまだスタイルがありません。
私のログに次のようになり、エラーのスルーもあります:私は
Started GET "/assets/defaults.js?body=1" for 127.0.0.1 at 2011-12-22 14:35:36 -0600
[2011-12-22 14:35:36] ERROR NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
/Users/kevin/.rvm/gems/[email protected]/gems/rack-1.3.5/lib/rack/handler/webrick.rb:71:in `service'
/Users/kevin/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/kevin/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/kevin/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
cache: [GET /assets/defaults.js?body=1] miss, store
Served asset /defaults.js - 200 OK (1ms)
何をしないのですか?
セッションストアにmemcachedを使用しているのでしょうか? –