Octothought

thinking about things from eight sides

Precompiling Assets for a Rails Engine on Heroku

I’ve been working on a project which is a Rails Engine and recently struggled through getting the engine’s asserts working within an app on Heroku. Because of how Heroku sets up the environment for the asset precompiliation step (or doesn’t set up the environment, as it happens), they recommend disabling the initialize_on_precompile setting (many apps are unable to complete their normal initialization without their Heroku environment config, which isn’t available during Heroku’s build process; turning off initialization during precompilation avoids that).

CocoaConf PDX 2013

Although most of my work is on web applications and services, I also dabble in Objective-C, iPhone, and Mac development (someday I hope to ship some of it…). As luck would have it, CocoaConf happened to have a stop in my hometown, and it was at a hotel out near the airport, so I could just hop on the MAX to get there. The early registration price was a pretty reasonable number by conference standards, so I decided to check it out and see what I could learn to help me get going on some of my own projects.

In short, it was a great conference—well worth the cost of admission and the time spent. There were two days of really great talks (and a third day of tutorial/workshop sessions that I didn’t attend) put together by developers who really want to share their knowledge.

Things I Learned: Git Add Your Gem’s Generator Files

Background

I’ve been spending some of my free time creating a Ruby Gem for Rails apps that makes it easy to set up tables with fixed data that you want to always be present in your database: static-data. This is handy for lookup tables, predefined category lists, and other such things.

The Problem

I created some new files to add a new rails generator to static-data, I built and installed my gem, and… nothing. In researching other people’s challenges in getting their generators to work, I tried moving my generator file all over the place. I even tried adding extra code to my railtie to tell Rails where the generator file was, but that just caused rails generate to blow up entirely when it couldn’t find my generator file.