How would I set up a Rails-style Public dir in a Gem?

I am working on a Rails CMS gem. I want the Gem to have its own Public
dir (like Rails) to hold css/js/images etc... I have been trying a lot
of different pathing options from my Gem-centric views, but no matter
what I try I can't target any of the files.

Any thoughts on how to set this up?

Thanks, Elliott G

I am working on a Rails CMS gem. I want the Gem to have its own Public
dir (like Rails) to hold css/js/images etc... I have been trying a lot
of different pathing options from my Gem-centric views, but no matter
what I try I can't target any of the files.

Any thoughts on how to set this up?

I don't recall the plugin/gem that did this, but it ran all of the css/js/images through Rails routes with caching. So you get penalized that first time, but from then on they are cached...

Or you might override compute_path() and have it look in your gem/public directory first or last if it doesn't already exist, etc.

-philip

I don't think you can do what you're trying to do in Rails alone,
however, I'd appreciate to be shown wrong. The reason is that public is
not handled by your application at all. Rather, requests to files in
public are handled by the web server -- and that's a good thing, because
apache or nginx are much faster at serving static files than Rails
proper would be.

I take it, the usual way to add assets from a gem is to include a
generator that copies (or links) these assets to the application's
public directory.

Michael

Elliott Golden wrote:

I am working on a Rails CMS gem. I want the Gem to have its own Public
dir (like Rails) to hold css/js/images etc... I have been trying a lot
of different pathing options from my Gem-centric views, but no matter
what I try I can't target any of the files.

Any thoughts on how to set this up?

ln -s mygem/public RAILS_ROOT/public/mygem

I'm not convinced that this is a great idea.

Thanks, Elliott G

Best,

Thanks for the helpful input guys!

I may end up just using a generator to move a dir to Rails public.
That would work, I just prefer the idea of the Gem encapsulating
everything so that when a user updates the Gem they will have all the
new assets without having to run an "update" task or generator.

Elliott G