# Best Approach for Master/Slave Form SELECTs

**URL:** <https://www.ruby-forum.com/t/best-approach-for-master-slave-form-selects/147345>\
**Category:** Rails\
**Created:** [August 31, 2008, 6:30pm UTC](https://www.ruby-forum.com/t/best-approach-for-master-slave-form-selects/147345 "2008-08-31T18:30:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [August 31, 2008, 6:30pm UTC](https://www.ruby-forum.com/t/best-approach-for-master-slave-form-selects/147345/1 "2008-08-31T18:30:49Z")

</div>

I want to have the second select options dependent on the selection of  
the first select option. Is this built into Rails? I haven’t seen it.

I’d rather not right JavaScript and Ajax to pull values in background  
unless necessary.

Pete

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [August 31, 2008, 6:43pm UTC](https://www.ruby-forum.com/t/best-approach-for-master-slave-form-selects/147345/2 "2008-08-31T18:43:38Z")

</div>

Hi Peter,

Peter A. wrote:

> I want to have the second select options dependent on the  
> selection of the first select option. Is this built into Rails?

No.

> I’d rather not right JavaScript and Ajax to pull values in  
> background unless necessary.

It’s necessary, but not difficult. You put an observe\_field on the  
first  
select that calls a controller method when the select changes, passing  
along  
the value selected. The controller method (re)renders the second select  
via  
rjs, either inline in the method or via a separate rjs view. Search the  
list archives. The question’s been asked / answered many, many times.

HTH,  
Bill
