Archive for November, 2009

You are currently browsing the memamsa archives for November, 2009.


Rails-style jQuery UI Menu

Some people love the drop-down, drill-down fly-out menu, which is now working its way into the official jQuery UI code-base.

The menu looks great, but is a bit tedious to construct. In fact, its downright onerous for the railszers used as we are to select_tag and options_for_select.

Ruby to the rescue!

The rails-jquery-dropdown helper generates the drop-down HTML markup, places menu items and values and optionally sub-menus using a passed-in Array, and wires up the Javascript behavior using jQuery.

Get it from GitHub:
http://github.com/dkeskar/rails-jquery-dropdown

On News

The TiE Oregon event on Unfolding News was a frank and insightful discussion anchored by newspaper veteran Peter Bhatia and news entrepreneur Steve Woodward.

News about newspapers is either increasingly dire, or dramatic. The list of defunct newspaper continues to grow. Online, a news mogul mulls withdrawing news content from the Google index. Sitting face-to-face and talking with thoughtful people with real stories from the trenches quickly brings into focus the salient issues.

Here are some of the key points from the discussion. Read the rest of this entry »

AirDB Join Table Attributes

In some cases, it becomes necessary to have additional attributes associated with a many-many relationship.

This is typically true of “has_and_belongs_to_many” associations which end up mirroring some kind of “membership” between the joined models. For example, a library system might track borrowing of books by patrons, with extra attributes for return dates and accrued fines.

The Django guys have a handy example about musicians and bands with extra attributes such as the membership role and date of joining. In my case, I needed to track sharing status of Photos across Photosets.

AirDB now has support for such join table attributes. Its a bit of a hack, in the interests of time, code size and abstraction concessions. The new things, which make it all possible include:

  1. An optional argument to Migrator.joinTable()
  2. DB.execute(sql) to allow tweaking an existing join table.
  3. Associator methods: setAttrfindAllByAttr, countByAttr, getAttrVal.

Here are some actual code excerpts (in the Photoset model) Read the rest of this entry »