Rails 3.1 introduced the asset pipeline. One of the very cool things you can do now, is using a regular Ruby gem to include assets for your project:
group :assets do
gem "jquery-rails"
gem "chosen-rails"
end
Many asset libraries are not maintained as a Ruby gem and with the Rails Engine folder structure. Think jQuery, but also something like the Chosen library (https://github.com/harvesthq/chosen). As a result, many gems are popping up that transform the original library into a Ruby/Rails Engine gem. An example for chosen is the chosen-rails gem (https://github.com/tsechingho/chosen-rails).
So far, so good: we can include the Chosen library as an asset into our Rails 3.1 project. But the following problems can arise:
- The original library is updated, but the Rails gem needs an update too. By clever use of Thor this can be as simple as a single
rake update-chosen
, but we are still in the favors of thechosen-rails
maintainers how fast the new gem is pushed. - You want to improve the original Chosen library by forking the Chosen Github repository. It just happens that changes are not pulled into master and you want to keep using an alternative repository with the library. Because the
chosen-rails
gem has an hardcoded link to the original Chosen library, you also need to forkchosen-rails
and update the source files with the files from your own repository.
These two problems have forced me to include some libraries in the old fashion way into our Rails projects. In my opinion the upswing of small asset gems for other libraries is not a good thing. We should find a way to translate the original source code into a Rails asset gem.