On Fri, Nov 16, 2007 at 09:19:11AM -0600, Michael D. Ivey wrote: > Tuples as URL segments...interesting. My brain immediately went to > /monkeys/[koko,pops] but that's not legal. After spending too much > time in the spec when I should be getting ready for work, I came up > with this: > > /monkeys;koko,pops > > ; signifies params for a path segment....so it says "the collection > of monkeys, limited by this tuple" ... legal, semantic....kinda > pretty if you're a URI geek, too.
FWIW, Rails have dropped their use of the semicolon, apparently because of some compatibility problems. i.e. they now use /monkeys/123/squawk instead of /monkeys/123;squawk See: http://weblog.rubyonrails.org/2007/10/5/rails-1-2-4-maintenance-release Given that a tuple is always of fixed size, I would be inclined towards /monkeys/koko/pops, if only because (a) in the degenerate case of the single-key tuple it's the same as now, and (b) it doesn't introduce any more characters which need escaping if they occur within the key columns. Given a composite key, perhaps the router should set the 'id' parameter to an array? This would be convenient if the ORM supports composite keys in this way, as you could still do Monkey.find(id) # id = ['koko','pops'] I don't know which, if any, ORMs would support this. But in any case you can always do Monkey.find_by_firstname_and_lastname(*id) || (raise "No banana") But in any case maybe it's better to name the key components explicitly, e.g. r.resources :monkeys, :resource_id=>[:firstname,:lastname] which could just build a pattern of monkeys/:firstname/:lastname and the routing code wouldn't have to change. > Anyway, interesting stuff, thanks for the email. I didn't see an > official entry into the contest, though. :) I don't know what the prize is, but I can probably live without it :-) Regards, Brian. _______________________________________________ Merb-devel mailing list [email protected] http://rubyforge.org/mailman/listinfo/merb-devel
