How to create and publish gems?
If you are new to this topic please follow my older post. https://cbabhusal.wordpress.com/2015/03/08/ruby-how-to-create-a-gem-for-beginner/
How to integrate jQuery Plugins with Ruby Gems?
To make your gem assets available to your user’s application.js / .css files you need to modify your module. Suppose your gems name is momentjs_modified-rails then you need to add a Rails::Engine subclass in your main module. For Example:
require "momentjs_modified-rails/version" module MomentjsModified module Rails class Engine < ::Rails::Engine end end end
Adding the following snippet will cause rails to add its directories to the load path when the gem is required.
class Engine < ::Rails::Engine end
Now you will keep you asset files in proper directories
Add The Assets
Download the asset files you want to include in the gem. If availble, I prefer to use the uncompressed, non-minified versions. They’ll actually be readable if you need to dig into them and you can rely on the asset pipeline to minify them in production or on precompilation. In the case of the Moment.js library, I downloaded the release version to my desktop and ran the following commands:
I used the
vendor/assets directory here because these aren’t assets I’m maintaining directly. If they were assets I was responsible for maintaining, I would put them in
app/assets though the difference is purely semantic.