I have created a gem with a vendor directory containing stylesheets and javascripts from bootstrap-sass and bootstrap itself.
The directory structure is bootstrap-sass-gem/vendor/assets/javascripts
and
bootstrap-sass-gem/vendor/assets/stylesheets
I've required the gem in a test project but whenever I try to require something from that gem I receive a Sprockets::FileNotFound
error.
For instance, in application.css I added *= require bootstrap
.
bootstrap is located at bootstrap-sass-gem/vendor/assets/stylesheets/bootstrap.scss
and so by my reckoning should be included in the asset pipeline.
I'm running RVM Ruby 1.9.2 and Rails 3.1.
Here's my config file:
$:.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 = ["[email protected]"]
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
The problem was with my require_paths variable. The correct setting should have been:
s.require_paths = ["lib"]
I had the same problem, I solved it adding a dummy engine. This way in rails 3.1 the assets path was added automatically to Rails.application.config.assets.paths.
Since Rails 3.0, if you want a gem to automatically behave as an engine, you have to specify an Engine for it somewhere inside your plugin’s lib folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With