Topic: Sharing JS/CSS in gems
At my company we have multiple Rails applications. We have a need to share code across all the applications for reuse. In upgrading our applications to Rails 3 we are moving reusable code to be shared code across applications into gems. Some helpers that we've pushed into gems reference JS/CSS that is assumed to be provided by the app. We are sharing this JS/CSS today via an svn external pulled in on the application level. The tight coupling across the gem and svn external doesn't sit well with us. Ideally, we'd push the JS/CSS into the helper gem itself or otherwise into a new gem and make it a dependency of the helper gem.
1. What is the best way to share JS/CSS code across apps?
2. Are gems the right vehicles for sharing JS/CSS? Assuming the JS/CSS is packaged inside of gems, how does the application reference the JS/CSS files?
3. Does anybody else have cases where reusable code in gems reference JS/CSS?
4. How do others reuse/share JS/CSS across applications?
Our current thinking for this is to use symlinks under public/ to point to public directories within the gems. For example:
[Rails root]/public/my_sweet_gem/ -> [LOCAL GEM REPO]/my_sweet_gem-1.0.0/public/
A request for /my_sweet_gem/some_file.js would resolve to [LOCAL GEM REPO]/my_sweet_gem-1.0.0/public/some_file.js
Symlinks would be created (if necessary) when the application boots up in development/test and during a deployment step for production.
Anybody else do something like this?