如何配置Rails Assets管道以使用Formtastic的css

时间:2011-10-13 12:28:59

标签: ruby-on-rails

应用程序/资产/样式表/ application.css

*= require formtastic

我收到此错误:

rake assets:precompile 
/Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby /Users/Nerian/.rvm/gems/ruby-1.9.3-rc1@davinci/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
*/

2 个答案:

答案 0 :(得分:4)

评论组内有该行吗?它应该是:

/*
*= require formtastic
*/

我不认为开发模式会编译文件,而是单独为它们提供服务,这样就可以解释为什么当时没有错误......

答案 1 :(得分:2)

只是想添加答案以防其他人遇到同样的问题。

我有这个:错误

/*= require reset
 *= require main
 */

但我需要更改第一行:正确

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