Sharing CSS with Ruby Gem

We have a common CSS style in our organization that is used by most projects. These assets (css, images, etc.) are included in each project source code.

I would like to have a gem that could place these assets, and projects that use this gem will be able to use them directly. At the moment, I can only find ways to use generators and “install” assets in the project, and not use them from the gem itself.

The basic requirement is that if correction / improvement of errors was made to the assets, just updating the gem should get me in all projects that use the updated gem.

How can i do this?

+3
source share
1 answer

You can do this quite easily in rails 3.1+ if you make your gem an engine of rails. Among other things, if you add assets to the engine, you can require these CSS files from application manifest files, etc.

See how to do it here and quite a few stones that wrap js / CSS packages for this exact purpose, the ability to update used assets without running generators or anything else. For example, jquery-rails gem does this for jquery. A more complex example is jquery-ui-rails, which combines all jquery ui js, CSS, images, etc. And it allows you to load only jquery ui components that you really need.

+2
source

All Articles