Daniel X Moore
Daniel X Moore

Reputation: 15060

Arbitrary Sprockets asset path in assets only gem for Rails/Sprockets

I'm trying to make and distribute a Ruby Gem where I package CoffeeScript files for use in other applications.

It works fine in most Sprockets apps, but when I try to include it in a Rails App I get:

undefined method `append_path' for Sprockets:Module

The error is from this line:

::Sprockets.append_path File.join(root_dir, "source")

How come when using the gem in a Rails app Sprockets has no append_path method? Is there a way to get Rails apps look in a specific directory for asset files?

I don't want to put my files in app/assets/javascripts because this is an assets only app and burying them like that just to accomodate Rails is aesthetically displeasing.

Upvotes: 0

Views: 633

Answers (2)

Daniel X Moore
Daniel X Moore

Reputation: 15060

class Engine < ::Rails::Engine
  config.paths['app/assets'] = "source"
end

Upvotes: 1

RoRRe
RoRRe

Reputation: 291

Which version of rails are you using. Sprockets has been included in rails.

check out http://guides.rubyonrails.org/asset_pipeline.html

Upvotes: 0

Related Questions