2011-10-13 51 views
3

應用程序/資產/樣式表/ application.css如何配置Rails的資產管道使用Formtastic的CSS

*= require formtastic 

我得到這個錯誤:

rake assets:precompile 
/Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby /Users/Nerian/.rvm/gems/[email protected]/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets 
rake aborted! 
Invalid CSS after "*": expected "{", was "= require formt..." 
    (in /Users/Nerian/Projects/davinci/app/assets/stylesheets/application.css) 

Tasks: TOP => assets:precompile:primary 
(See full trace by running task with --trace) 
rake aborted! 
Command failed with status (1): [/Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/b...] 

所以rake任務不工作,但奇怪的是,當我在開發中運行應用程序時,由於我可以看到正在應用的formtastic css,所以資源被編譯。

我在做什麼錯?

編輯:

/* 
* This is a manifest file that'll automatically include all the stylesheets available in this directory 
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 
* the top of the compiled file, but it's generally better to create a new file per style scope. 
*= require_self 
*= require_tree . 
*= require formtastic 
*= require my_formtastic_changes 
*/ 

回答

4

是一個註釋組內部的線?它應該是:

/* 
*= require formtastic 
*/ 

我不認爲發展模式編譯的文件,而是單獨爲他們服務的,這樣也許可以解釋爲什麼有當時沒有錯誤...

+0

這是有一個註釋組之外。我把它們放在裏面,現在它工作:) – Nerian

2

只想補充到任何其他人遇到同樣問題的答案。

我有這樣的:錯誤

/*= require reset 
*= require main 
*/ 

但我需要改變的第一行:

/* 
*= require reset 
*= require main 
*/