[LRUG] REST and Associations

Jonathan Leighton turnip at turnipspatch.com
Thu Feb 22 14:32:21 PST 2007


Just picking a choosing a few questions to answer :)

On Thu, 2007-02-22 at 22:02 +0000, Roland Swingler wrote:
> 1. From what I've read, I thought all urls were meant to be nouns in
> restland - how does having /posts/1;edit give you any advantage over
> /posts/edit/1 or /posts/1/edit ? A semicolon does not a noun make. For
> me this highlights a possible weakness in thinking of everything as
> nouns - see Steve Yegge's "Kingdom of Nouns" article -
> http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html

I think the idea is that #edit isn't a "real" REST request. If the API
were being used, you'd just send a PUT to /posts/1 with all the data in
the request. But for a web application the user has to enter the data
somehow. Hence #edit.

> 3. Similarly what is the right way to do sorting/pagination? For
> example when I GET /posts I may want to only return the top ten in
> html - but what about in the xml respond_to do I return all of them or
> just ten? Is the idea that *exactly* the same resource(s) are
> returned, no matter the mime type or can _what_ is returned vary as
> well as _how_ it is returned?

Interesting question. I don't know the answer. I guess returning
everything in the XML would quickly become impractical, whether it is
"right" or not.

> 5. For nested resources, how do you avoid a dirty great switch
> statement in your controller if things can be nested under many
> different resources?

I haven't used nested resources, but this might help:
http://weblog.jamisbuck.org/2007/2/5/nesting-resources

> 7. How useful is ActiveResource - is anyone here using it? can you do
> much more than find a list of resources/resources by id - like the sql
> options in find()?

At the Rails exchange the other day it was mentioned briefly (I think,
maybe somebody said something in conversation). The impression I got was
that it looked nice in the demos but wasn't hugely practical.

> Any thoughts on any of these very very welcome - and as a call for
> talk ideas was raised earlier I would really appreciate a talk on REST
> that goes beyond the basics of here is a resource generated with the
> scaffold - "look now I can find a record with an id with
> ActiveResource" - anyone offering...?

I'll second that. I am thirsty for REST knowledge :)

Cheers,

Jon

-- 
Jonathan Leighton, Web Developer
Portfolio: http://jonathanleighton.com/
Personal: http://turnipspatch.com/




More information about the Chat mailing list