REST w/ multiple views

I have app that will need to be able to display records matching a
search
criteria. What is the RESTful way to do this? Just an plain index action
with search parameters? Should the query parameters be built into the
route?

Additionally, the records themselves will have multiple views associated
with them, ie: html & graphs, but all via a webpage. Would responds_to
be
the proper way to approach this?

Thanks in advance.

Mike,

If you can, also check out the Rails Recipes book. One of the recipes
is how to write a search controller and actions that are modular and
can be shared across multiple other controllers.

ESPNdev - thanks alot for the info. Da-da-da Da-da-da!

On Tue, Jul 22, 2008 at 6:16 PM, [email protected] <

Hey Mike

On Jul 22, 1:05 pm, “Mike Joslyn” [email protected] wrote:

I have app that will need to be able to display records matching a search
criteria. What is the RESTful way to do this? Just an plain index action
with search parameters? Should the query parameters be built into the route?

That’s how I would do it. Ideally you’ll have a Search object so that
it makes writing search rules more modular and results aren’t session-
based (and you can share them across users). Definitely include the
parameters in the URL if for no other reason because you’ll strengthen
your google juice.

Additionally, the records themselves will have multiple views associated
with them, ie: html & graphs, but all via a webpage. Would responds_to be
the proper way to approach this?

Well, for different representations responds_to is definitely the way
to go (json, xml, etc). You can define a custom responds_to as this
guy did for the iphone (http://blog.marcslove.com/2007/6/29/respond_to-
iphone-in-rails). Users could call http://yoursite.com/whatever.graph

Alternatively you could create a Graph scaffold and allow users to
access http://yoursite.com/graphs/whatever

If this is too vague let me know and I’ll try to help out further…

ESPNDev