我创建了一个带有供应商目录的gem,其中包含
bootstrap-sass和bootstrap本身的样式表和javascripts.
目录结构是
引导 – 萨斯 – 宝石/供应商/资产/ JavaScript的
和
引导 – 萨斯 – 宝石/供应商/资产/样式表
我在测试项目中需要gem,但每当我尝试从gem中获取某些内容时,我都会收到Sprockets :: FileNotFound错误.
例如,在application.css中我添加了* = require bootstrap.
bootstrap位于bootstrap-sass-gem / vendor / assets / stylesheets / bootstrap.scss,因此我的计算应该包含在资产管道中.
我正在运行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"]