我們正在將我們的應用程序從Rails 2升級到Rails 3.1,並且我在資產管道中遇到了問題。Rails 3.1資產管道沒有看到文件
我有我的配置/ application.rb中如下:
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'
在development.rb
,然後將此
# Do not compress assets
config.assets.compress = false
config.assets.debug = true
我知道這是不是爲所需的行爲管道,但我們這樣做是爲了確保當我們將升級合併到我們的主分支時,所有的舊文件都被正確計算。
然後我有以下文件,「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? – 2012-01-12 13:31:53