在资产管道路径中获取Gem供应商文件

我创建了一个包含bootstrap-sass和bootstrap自身的样式表和javascripts的供应商目录的gem。

目录结构是bootstrap-sass-gem / vendor / assets / javascripts

引导 - 萨斯 - 宝石/供应商/资产/样式表

我在测试项目中需要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"]

我遇到了同样的问题,我解决了它,添加了虚拟引擎。 这种方式在rails 3.1资源路径被自动添加到Rails.application.config.assets.paths。

从Rails 3.0开始,如果你想让一个gem自动作为引擎运行,你必须在你的插件的lib文件夹内的某个地方指定一个引擎。


我认为资产管道期望您的文件被命名为bootstrap.css.scss 。 我不确定,但是也许你需要定义一个railtie作为你的gem for rails以找到售卖的样式表

链接地址: http://www.djcxy.com/p/81107.html

上一篇: Get Gem vendor files in asset pipeline path

下一篇: Can't find the 'libpq