Challenge
Michael D. Ivey
ivey at gweezlebur.com
Fri Nov 16 10:19:11 EST 2007
On Nov 16, 2007, at 3:48 AM, Brian Candler wrote:
> Presumably it also has something like
> def index
> @monkeys = Monkey.find(:all)
> end
Yep just left them out for brevity. They're the standard CRUD actions.
> What do you mean by 'API' here? Or is the idea to explore all the
> possibilities which might be implied?
By "Perfect API" I meant, "Assume Merb is your Perfect Framework, and
works exactly as it should.
What would you have to change in your app, using Merb's perfect API,
to accomplish your task?"
> (2) modify Merb so the url() helper can use an arbitrary model
> field as the
> resource id, e.g.
>
> r.resources :monkeys, :resource_id => :name
You're at least the third person to suggest attaching this to the
routes, so that seems like an approach worth exploring for Merb.
> But if the idea is to add some feature to Merb for this
Well, it's both. Merb needs some way to handle not using the id
attribute of a model in URLs. Especially in the case where the
models aren't even database backed. But this is also a contest, for
making up cool and pretty APIs.
> I would suggest first a generalisation of the problem to allow for
> composite primary keys.
> e.g. if each monkey has a first name and last name, and the tuple
> (first name, last name) is unique, then allow resource URLs of the
> form
>
> /monkeys/koko/pops
> or /monkeys/koko;pops
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.
I can't decide without more linking and parsing if /
monkeys/;koko,pops would also be legal.
Anyway, interesting stuff, thanks for the email. I didn't see an
official entry into the contest, though. :)
More information about the Merb-devel
mailing list