2011-05-23 95 views
19

我得到這些警告當試圖在Rails 3.1 rc1中使用sass'sass'以非線程安全的方式

WARN: tilt autoloading 'sass' in a non thread-safe way; explicit require 'sass' suggested. 
WARN: tilt autoloading 'sass/plugin' in a non thread-safe way; explicit require 'sass/plugin' suggested. 

這是我的Gemfile。

gem "rails", "~> 3.1.0.rc1" 
gem "haml" 
gem "sass" 

我試圖創建一個名爲sass.rb包含此代碼的config/initializers內。

require "sass" 

將Gemfile更改爲此。

gem "rails", "~> 3.1.0.rc1" 
gem "haml" 
gem "sass", require: false 

但是警告依然存在。 任何人都知道如何解決它?

我發現the code即打印警告,如果這是任何幫助。

回答

13

你有沒有試過在Gemfile中做這個?

gem "sass", :require => 'sass' 

這是一個顯式調用,不使用初始值設定項。順便說一下,你認爲你使用的是rc1版本。

1

在Heroku上我收到了同樣的錯誤,並且使用谷歌搜索並沒有幫助我發現問題,所以我想我會添加我發現這個問題,因爲它在搜索時首先出現。

問題不在於這個錯誤,而是將代碼推到Heroku時的一個小錯誤。寶石上市後這些行讓我的路徑回答上:

Running: rake assets:precompile 
rake aborted! 
Tasks: TOP => environment 
(See full trace by running task with --trace) 
Precompiling assets failed, enabling runtime asset compilation 
Injecting rails31_enable_runtime_asset_compilation 
Please see this article for troubleshooting help: 
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting 

我剛剛一直在Heroku上配置Redis的,所以我知道,這個問題必須是一些涉及到這些變化。在那個URL,我發現這一點:

雖然預編譯的資產,在Rails的3.1.1及以上,可以防止你的初始化程序 並確保下面一行在你>的config /應用程序連接到數據庫.RB:

config.assets.initialize_on_precompile =假

添加on_precompile =假線固定所有的錯誤,包括原來在這個問題上。

3

我有同樣的問題,並能夠通過在文章中提到的Rails 3.1+ Asset Pipeline on Heroku Cedar

RAILS_ENV=production bundle exec rake assets:precompile 

我也試過Itecedors建議其還努力推到Heroku的前本地編譯資產來解決這個問題:

While precompiling assets, in Rails 3.1.1 and up, you can prevent initializing 
your application and connecting to the database by ensuring that the following 
line is in your > config/application.rb: 

config.assets.initialize_on_precompile = false