我创建了一个带有供应商目录的 gem,其中包含来自 bootstrap-sass 的样式表和 javascripts并自行引导。
目录结构为 bootstrap-sass-gem/vendor/assets/javascripts
和
bootstrap-sass-gem/供应商/ Assets /样式表
我在测试项目中需要 gem,但每当我尝试从该 gem 中请求某些东西时,我都会收到 Sprockets::FileNotFound
错误。
例如,我在 application.css 中添加了 *= require bootstrap
。
bootstrap 位于 bootstrap-sass-gem/vendor/assets/stylesheets/bootstrap.scss
,因此据我估计应该包含在 Assets 管道中。
我正在运行 RVM Ruby 1.9.2 和 Rails 3.1。
这是我的配置文件:
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "bootstrap-sass-gem/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "bootstrap-sass-gem"
s.version = BootstrapSassGem::VERSION
s.authors = ["James Smith"]
s.email = ["James@smithware.co.uk"]
s.homepage = "http://www.smithware.co.uk"
s.summary = "The Bootstrap-sass project Gemified"
s.description = "Description of BootstrapSassGem."
s.files = Dir["{lib,vendor,rdoc}/**/*"] + Dir["*"]
#s.test_files = Dir["test/**/*"]
s.require_paths = ["lib/**/*"]
# We are dependent on the asset pipeline in 3.1.0
s.add_dependency "rails", "~> 3.1.0"
# s.add_development_dependency ""
end
最佳答案
问题出在我的 require_paths 变量上。 正确的设置应该是:
s.require_paths = ["lib"]
关于ruby-on-rails - 获取 Assets 管道路径中的 Gem 供应商文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7531563/