Beware rendering multiple partials with layouts

Want to render more than one partial with the same layout in your page? Beware:

‘p1′, :layout => ‘layouts/p_layout’ %>
‘p2′, :layout => ‘layouts/p_layout’ %>

layouts/p_layout.html.erb

<hr/>

_p1.html.erb

Content!

_p2.html.erb

Content!

Did you expect this?

HeaderFor1 Content! FooterFor1

HeaderFor2 Content! FooterFor2

Nope. You get this:

HeaderFor1 Content! FooterFor1

HeaderFor1HeaderFor2 Content! FooterFor1FooterFor2

The instance variables in the layout object retain their values, even between invocations of render. My workaround […]

Rails LOC vs Java LOC

At my last client, we wrote a webservice in Java, it had perhaps 30 service calls and 3 endpoints. We worked on it for about 6 months.

$ find services -name *.java -exec wc {} \; | awk ‘{a+=$1;print a}’ |tail -1
64793

At my current client, we are writing a Rails web application. It’s been a living […]

Generate mod_rails httpd.conf using cap

With all the discussions around the new mod_rails, I thought I’d post the Apache conf that I came up with. Here’s the strategy: generate httpd.conf using cap, upload it to the server, and graceful restart Apache. This way, you don’t have to get your hands dirty logging into the box to reconfigure anything.
Here’s the […]