Archive for the 'ruby' Category

Which Weekend?! (new app)

For anyone who’s been following my extremely sparse postings - here’s something exciting to look at - http://whichweekend.com - small simple useful. A week’s work (in the evenings) and it was super fun. Like they say - build something you want to use! I’ll be rolling out new features this coming week or two, then back to polishing off courseway (which I admit has been on hold for a while).

Hidden counter in partial collections

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.rhtml (or rails 2 style _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

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?