我是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文件?感谢...
答案 0 :(得分:3)
在Rails从zurb-foundation gem中获取新资产之前,您需要重新启动Web服务器。重新启动后,它应该可以正常工作。
此外,您可以检查从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", "/Users/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/vendor/assets/stylesheets"]
请注意,您可能需要做一些额外的工作才能在生产中部署资产。
答案 1 :(得分:2)
以下是基于此帖子https://github.com/zurb/foundation/issues/834解决类似问题的方法 在Gemfile中添加了compass-rails gem:
group :assets do
gem 'compass-rails'
执行命令
bundle install
不要忘记重启网络服务器,魔法就会发生。
答案 2 :(得分:1)
您可以将此指令添加到application.css
文件中:
*= require_directory ./foundation
或者您可以使用foundation-rails
gem。