Gems & Libraries in Rails 3.2


Getting up to speed during my first week on the new job. My first task has been upgrading the versions of Ruby and Rails for the main website. To handle some of the common tasks across web applications, we use an in-house gem. While testing the upgrades, I noticed that some of the JavaScript libraries called in the web app weren’t being pulled out of the gem. It took some digging to discover why, but here’s what I found.

The libraries were previously located in the public/ directory of the gem, which the asset pipeline doesn’t check. The asset pipeline will only check the app/assets, lib/assets, and vendor/assets directories.

Solution: hop to the terminal and git mv the directories to lib/assets. Reload the server and the page, check the console, and boom—no more file not found errors.

On the HTML/HAML side, the library is still called in the app with = javascript_include_tag 'jquery-1.10.2.min.js' and we use = javascript_include_tag 'application' to grab all of the other, site-specific stuff. Same with the stylesheets helper. If you know of a more efficient way to do work the asset pipeline in Rails 3.2.17, let me know!

Still more cleaning and tweaking and wrestling of RefineryCMS to do. & don’t forget: Friday is Tie Day.

(If you work in the command line, the tree tool is pretty dang awesome, if only for the visualization: brew install tree to get it, so you can see your directories like a tree.)