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.
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.
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.
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.
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.