Sunday, August 21, 2011

Genericizing Rails view templates

In keeping with my previous post, I have put together a way of greatly reducing the redundant code in Rails views. On the HTML side, this really only applies to the simple case of rendering the default REST views provided by Rails' scaffolding mechanism.

Rather than have an index.html.haml (or erb if you're a bad person ;) for every model you have, why not consolidate all of those into a single template? They all do the same thing anyway: render a table of objects along with a few actions. Using the wonderful render_inheritable gem, you can define a single index.html.x file in a central location (such as app/views/application) and have all of the customization occur at runtime.

Scala on Android with Eclipse

Yes, I'm back from the dead. I've been busy starting a company of late and have been pretty much full speed ahead on that, leaving less (read: none) time for blogging.

Anyway, on with the main event: a working setup for developing Android applications in Scala. I spent about 3-4 days total trying to get this setup working, using various different schemes such as the Treeshaker plugin for Eclipse, the Maven Android plugin and others. After hours and hours of fiddling, I finally found a solution that works: a custom SBT setup with the SBT Android plugin. The key is to avoid building the Android app in Eclipse itself, but to use SBT for the heavy lifting.