Thursday, February 2, 2012

rails gotcha

Rails has improved my web development experience, no doubt but not without a few gotcha's. Somehow I missed this one, so hope this helps if anyone else did too:

One of the useful features of rails is the asset pipeline. Very flexible and designed to improve performance of rails apps overall - good stuff!

My preference is to pre-compile assets in my dev environment and simply copy these static resources to the proper destination (presumably to a cached store in your environment, CDN, mod_cache, etc). What wasn't apparent (obvious) from the docs is that you need to clean after compilation

rake assets:precompile
rake assets:clean

in your dev environment, otherwise bad things will happen. In my case, a javascript event handler was installed twice for the same event and caused some very odd behavior but difficult to troubleshoot. I wasted an entire afternoon fishing this one out, hopefully will save you some trouble - clean after precompile!

No comments:

Post a Comment