User search thru a database using the REST approach

How can you implement a search function using the REST approach? Is
there an example of this somewhere on the web? Thanks!

It would seem rather easy as far as you have two main options:

1) Think of the "search" itself as a resource
2) Think of the "search" as a condition of "index" action

For one, create the SearchController which will manage "search"
resources if you will. New will be the form to enter the search query,
and "create" will perform the search and return the results, etc.

For two, simply have the "index" action accept optional query
conditions. So, by default, index would display all the items and then
by specifying constraints, this could also act as a search of sorts.

Hope that helps.

Thanks, Nathan! I think I'm finally getting the hang of this REST
approach and am starting to like it. Urls are so much cleaner and it's
starting to make sense! Cheri

Good suggestion, Nathan. I think the main question (for Cheri) to
answer is whether Search is something that is going to be needed for
many different models or simply this one. If it's something that will
be done for many things and you need to render a consistent list then
go with 1; if it's primarily one (or two) models then go with 2.

The search will be needed for just one model, so I will go with option
2. I also plan to include the search terms in the url for the search
results view- which I assume under the REST model would be the search
"show" view - so that the user can use the Back button to get back to
the search results page. - Cheri

AndyV wrote: