2012-04-14 33 views
3

我的應用程序在haml和scss的指南針和sussy的開發環境中正常工作,並且應用程序的Gemfile配置爲 - :Gist for GemfileRails 3.1.3使用指南針+ sussy + haml + scss編譯資產時出現登臺服務器錯誤

和我的application.rb中設置是這樣的 - :

if defined?(Sass) 
config.sass.load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets" 
config.sass.load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/blueprint/stylesheets" 
config.sass.load_paths << "#{Gem.loaded_specs['compass-susy-plugin'].full_gem_path}/sass" 
end 
config.assets.precompile << /(^[^_]|\/[^_])[^\/]*/ 

但是,當我部署我的應用程序服務器。這是在分段環境。總是拋出我的錯誤 - :

Error compiling asset application.css: 
    Sass::SyntaxError: Undefined variable: "$base-font-size". 
    (in /var/www/App-staging/releases/20120405100127/app/assets/stylesheets/_mobile-first.scss) 
    Served asset /application.css - 500 Internal Server Error 

如果我嘗試提供一些黑客和補丁給我的錯誤 - :

Compiled application.css 
Completed 500 Internal Server Error in 419ms 

ActionView::Template::Error (File to import not found or unreadable: compass/css3/. 
Load path: Sass::Rails::Importer 

所以是這是指南針的問題和軌道版本? Ans有沒有永久的解決方案來擺脫這個或任何工作配置的舞臺和生產環境。 感謝您的幫助。

回答

0

你確定你的部署腳本呼籲資產:預編譯與RAILS_ENV設置爲分期像這樣:

bundle exec rake assets:precompile RAILS_ENV=staging 

你能在開發機器上運行上述命令?

+0

沒有它給出了錯誤 未定義的方法'sass'爲# 2012-04-14 20:47:58

1

確保您導入使用

"import _mobile-first"; 

另外SASS文件,在軌3.1,正確的文件名會

mobile_first.css.erb.scss 

注:您不需要前導下劃線。

這將允許您使用scss導入導入文件,同時仍使用erb插入資產使用資產路徑助手。

<%= asset_path 'twitter.png' %> 

您正在使用老版本的指南針gem。升級到0.12.1。

如果仍然不行,請嘗試從application.rb中

if defined?(Sass) 
config.sass.load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets" 
config.sass.load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/blueprint/stylesheets" 
config.sass.load_paths << "#{Gem.loaded_specs['compass-susy-plugin'].full_gem_path}/sass" 
end 

刪除這些行你不需要他們。沒有他們的應用程序將運行良好。我從來沒有需要將這些行添加到application.rb

如果仍然不起作用,請刪除以下行並嘗試。

config.assets.precompile << /(^[^_]|\/[^_])[^\/]*/ 

如果這仍然不起作用,您可以發佈mobile_first.scss以及application.scss的內容嗎?

+0

您還在使用舊的gem版本的指南針。嘗試升級到最新版本 – Arpancj 2012-04-15 18:34:19