# Rest + ajax (rjs)

**URL:** <https://www.ruby-forum.com/t/rest-ajax-rjs/69246>\
**Category:** Rails\
**Created:** [September 19, 2006, 5:50pm UTC](https://www.ruby-forum.com/t/rest-ajax-rjs/69246 "2006-09-19T17:50:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Walker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9de053/32.png) [@Ryan\_Walker](https://www.ruby-forum.com/u/Ryan_Walker)\
**Post date:** [September 19, 2006, 5:50pm UTC](https://www.ruby-forum.com/t/rest-ajax-rjs/69246/1 "2006-09-19T17:50:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ryan\_Walker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9de053/32.png) [@Ryan\_Walker](https://www.ruby-forum.com/u/Ryan_Walker)\
**Post date:** [September 19, 2006, 6:10pm UTC](https://www.ruby-forum.com/t/rest-ajax-rjs/69246/2 "2006-09-19T18:10:26Z")

</div>

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](http://jystewart.net)  
Play : [http://james.anthropiccollective.org](http://james.anthropiccollective.org)
