Archive for the ‘ruby’ category

Hidden counter in partial collections

February 4th, 2008

A quick tech post to share knowledge:

If you need a counter, iterator, index, loop variable number type thing inside a partial rendering a collection then you can simply use an undocumented counter called [partialname]_counter.

render :partial => 'parrot', :collection => @parrots

Then in _parrot.html.erb you can use:

parrot_counter

I like this like I like each_with_index. :)

Rails2 foot note: I think the :collection option can be dropped in my example with the names I’ve used here but I’ve left it in for clarity.

Capistrano & Dreamhost

November 3rd, 2006

I’ve been having the problem on dreamhost whereby I capistrano up my app, the fcgi processes restart ok, but then the changes don’t seem to have taken effect. Even with multiple reapings it wouldn’t pick up the new version. Very frustrating.

At first I thought it was some sort of caching issue, but then I worked out that if I kill all the dispatchers then the new one that spawns picks up the new version. My knowledge of this stuff is all too superficial!

  • Should there normally only ever be one dispatch.fcgi process running?
  • When there are zombie dispatchers, does a random one get used for each request? (It seems so.)
  • Why doesn’t the reaper make the process pick up the new version?