Rest + ajax (rjs)

I’ve read most of the Ruby/Rails books, but I’m struggling with this:
How do
you combine simple AJAX UI actions with RESTful controllers?

In my app, I want to keep all controllers REST-compliant. On a form, I
want
one select dropdown filter the options in another select. So I read
several
ajax ways I can do that. But they all seem to point to hitting an action
on
the controller, which would be outside of REST (the action wouldn’t be
INDEX, NEW, CREATE, SHOW, EDIT, UPDATE, DESTROY). I see in the e-book
RJS
Templates for Rails how to build RJS-based site, but is an Ajaxed-out
site
just going to have controllers with more than 7 actions, or am I missing
something?

-Ryan

On Sep 19, 2006, at 11:40 AM, Ryan Walker wrote:

Rails how to build RJS-based site, but is an Ajaxed-out site just
going to have controllers with more than 7 actions, or am I missing
something?

I’m guessing you want an action that will return a list of items for
the second dropdown? If so, you should be able to pass a query string
to your index action to filter the results it returns.

eg. a GET to /controller/?month=september

would restrict the list that the index returns to only results in
september. That seems pretty RESTful to me – it’s using appropriate
HTTP methods to request a list of resources with some simple
filtering based on the query string.

Your index.rjs can then work with that data.

James.


James S. : Freelance Web D.
Work : http://jystewart.net
Play : http://james.anthropiccollective.org