1

我是 Rails 的新手。我安装了 Zurb 基础前端框架,如下所述:http ://www.zurb.com/article/814/yetify-your-rails-new-foundation-gem-and-

当我打开 app/assets/stylesheets/application.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 foundation
*= require_tree . 
*/

但是,在我看来,这条线

<%= stylesheet_link_tag    "application" %>

不加载我创建的文件 zurb_foundation/app/assets/stylesheets/foundation/index.css:

couldn't find file 'foundation'
(in /Users/migu/railsapps/maneki1/app/assets/stylesheets/application.css:6)

如何让它加载我放在 zurb_foundation/app/assets/stylesheets/foundation/ 下的文件和所有 CSS 文件?谢谢...

4

3 回答 3

3

在 Rails 从 zurb-foundation gem 获取新资产之前,您需要重新启动网络服务器。重新启动后,它应该可以正常工作。

此外,您可以检查是否从 rails 控制台正确找到了 zurb-foundation 资产。在命令提示符下,输入“rails c”,然后输入“Rails.application.config.assets.paths”(两个命令都减去引号)。您应该会看到如下内容:

=> ["/Users/MYUSER/appPath/app/assets/images", "/Users/MYUSER/appPath/app/assets/javascripts", "/Users/MYUSER/appPath/app/assets/stylesheets", "/用户/MYUSER/appPath/vendor/assets/stylesheets", "/Users/MYUSER/.rvm/gems/ruby-1.9.3-p0/gems/jquery-rails-1.0.19/vendor/assets/javascripts", " /Users/MYUSER/.rvm/gems/ruby-1.9.3-p0/gems/zurb-foundation-2.1.0/vendor/assets/images", "/Users/MYUSER/.rvm/gems/ruby-1.9. 3-p0/gems/zurb-foundation-2.1.0/vendor/assets/javascripts", "/Users/MYUSER/.rvm/gems/ruby-1.9.3-p0/gems/zurb-foundation-2.1.0/供应商/资产/样式表"] 

请注意,您可能需要做一些额外的工作才能将资产部署到生产环境中。

于 2011-12-05T15:06:45.980 回答
2

这是我基于此线程解决类似问题的方法https://github.com/zurb/foundation/issues/834 在 Gemfile 中添加了 compass-rails gem:

group :assets do
  gem 'compass-rails'

跑:

bundle install

不要忘记重新启动网络服务器,魔法就会发生。

于 2012-11-22T12:58:43.393 回答
1

您可以将此指令添加到您的application.css文件中:

 *= require_directory ./foundation

或者你可以使用foundation-rails宝石。

于 2011-12-03T20:57:36.623 回答