我有一个现有的 Rails 3.2.14 应用程序,我正在尝试将 zurb-foundation 添加到其中。我已经添加了 zurb-foundation gem 并运行了安装生成器。
我的问题是,每当我尝试加载页面时,都会收到此错误:
couldn't find file 'foundation'
当 Sprockets 击中
//= require foundation
application.js 中的行
问题似乎是包含来自 zurb-foundation gem 的资产的目录没有被添加到加载路径中。相比之下,我有一个我最近生成的应用程序,从一开始就包括zurb-foundation,@asset_paths.asset_environment.paths 包括以下内容
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.0/scss",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.0/js"
不包含在我正在更新的应用程序的资产加载路径中。相反,我得到了(在 better_errors 诊断窗口中使用 p @asset_paths.asset_environment.paths)
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/images",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/stylesheets",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts"
有趣的是,如果我在开发模式下运行控制台并查看 Rails.application.config.assets.path,它包括:
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/images",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/stylesheets",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.1/scss",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.1/js"
并且确实包括 zurb-foundation 资产路径。
我已将 gem 'zurb-foundation' 包含在资产组、开发组和任何组之外。我在新应用程序中使用 zurb-foundation-4.3.1。
我的 Gemfile 资产组是:
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'compass-rails'
gem 'zurb-foundation'
end
这个问题似乎类似于带有 ZURB Foundation 的 Sprockets::FileNotFound,尽管 Jurriaan 没有提到资产加载路径。
知道我可能会错过什么吗?
谢谢!