# Best Approach for Master/Slave Form SELECTs

**URL:** <https://discuss.rubyonrails.org/t/best-approach-for-master-slave-form-selects/33830>\
**Category:** rubyonrails-talk\
**Created:** [August 31, 2008, 4:30pm UTC](https://discuss.rubyonrails.org/t/best-approach-for-master-slave-form-selects/33830 "2008-08-31T16:30:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [August 31, 2008, 4:30pm UTC](https://discuss.rubyonrails.org/t/best-approach-for-master-slave-form-selects/33830/1 "2008-08-31T16: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:** ![Bill\_Walton](https://avatars.discourse-cdn.com/v4/letter/b/f07891/32.png) [@Bill\_Walton](https://discuss.rubyonrails.org/u/Bill_Walton)\
**Post date:** [August 31, 2008, 4:44pm UTC](https://discuss.rubyonrails.org/t/best-approach-for-master-slave-form-selects/33830/2 "2008-08-31T16:44:30Z")

</div>

Hi Peter,

Peter Alvin 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
