# Beginner question...really

**URL:** <https://www.ruby-forum.com/t/beginner-question-really/106267>\
**Category:** Rails\
**Created:** [June 7, 2007, 11:09pm UTC](https://www.ruby-forum.com/t/beginner-question-really/106267 "2007-06-07T23:09:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anitawa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@anitawa](https://www.ruby-forum.com/u/anitawa)\
**Post date:** [June 7, 2007, 11:09pm UTC](https://www.ruby-forum.com/t/beginner-question-really/106267/1 "2007-06-07T23:09:42Z")

</div>

Hi,

I want to create a select form and based on what the user chooses on  
the select form, I want to connect to different tables and display the  
content.

I’m clueless on how to go about it.  
Any pointers would be appreciated.

---

<div class="post-metadata">

**Author:** ![anitawa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@anitawa](https://www.ruby-forum.com/u/anitawa)\
**Post date:** [June 7, 2007, 11:25pm UTC](https://www.ruby-forum.com/t/beginner-question-really/106267/2 "2007-06-07T23:25:44Z")

</div>

On 6/7/07, anitawa [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> >

The select helper is your friend

[http://api.rubyonrails.com/classes/ActionView/Helpers/FormOptionsHelper.html#M000506](http://api.rubyonrails.com/classes/ActionView/Helpers/FormOptionsHelper.html#M000506)

–  
Cyril M.

---

<div class="post-metadata">

**Author:** ![anitawa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@anitawa](https://www.ruby-forum.com/u/anitawa)\
**Post date:** [June 8, 2007, 1:08am UTC](https://www.ruby-forum.com/t/beginner-question-really/106267/3 "2007-06-08T01:08:52Z")

</div>

Thanks…  
i got the select option set up…but how would i get data from  
diffrerent tables depending on user’s choice?

---

<div class="post-metadata">

**Author:** ![anitawa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@anitawa](https://www.ruby-forum.com/u/anitawa)\
**Post date:** [June 8, 2007, 1:13am UTC](https://www.ruby-forum.com/t/beginner-question-really/106267/4 "2007-06-08T01:13:52Z")

</div>

Hi there,  
I’m not sure if this is exactly what you want but it got me going down  
the right path a while ago:

> **[Radar - O’Reilly](https://www.oreilly.com/radar/?page=5)**
>
> Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology

This will walk you through getting specific data into the select form  
from a db table.

There’s also a way to do this with AJAX auto\_complete

[http://slash7.com/articles/2005/8/13/ajaxariffic-autocomplete-with-scriptaculous](http://slash7.com/articles/2005/8/13/ajaxariffic-autocomplete-with-scriptaculous)

Hope this helps!

Tyler

On Jun 7, 5:07 pm, anitawa [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > I want to create a select form and based on what the user chooses on  
> > > –

Cyril M.

---

<div class="post-metadata">

**Author:** ![anitawa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@anitawa](https://www.ruby-forum.com/u/anitawa)\
**Post date:** [June 8, 2007, 1:16am UTC](https://www.ruby-forum.com/t/beginner-question-really/106267/5 "2007-06-08T01:16:52Z")

</div>

Thanks…i dont think i was clear

im not looking to populate the select form from db table.  
im looking to get data off different db tables depending on the choice  
that the user makes from the select form.

On Jun 7, 4:13 pm, “removed\_email\_address@domain.invalid”

---

<div class="post-metadata">

**Author:** ![anitawa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@anitawa](https://www.ruby-forum.com/u/anitawa)\
**Post date:** [June 8, 2007, 8:08am UTC](https://www.ruby-forum.com/t/beginner-question-really/106267/6 "2007-06-08T08:08:29Z")

</div>

On 6/8/07, anitawa [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks…i dont think i was clear
> 
> im not looking to populate the select form from db table.  
> im looking to get data off different db tables depending on the choice  
> that the user makes from the select form.

You can get from different Table of you page form.

If you want create a User and in this page, you have a link to School.

You can made a select for all school that you have with

\<%= select :school, school\_id, School.find(:all).collect {|s| [  
s.name, s.id ] } %\>

After you have the school\_id good for creation and when you made the  
creation, you have link to School.

Else, you can define the param as you want and use it like an other  
params.

–  
Cyril M.

---

<div class="post-metadata">

**Author:** ![anitawa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@anitawa](https://www.ruby-forum.com/u/anitawa)\
**Post date:** [June 8, 2007, 10:44am UTC](https://www.ruby-forum.com/t/beginner-question-really/106267/7 "2007-06-08T10:44:46Z")

</div>

Hi,

if I understand correctly – the visitor’s selection will be available  
for you in params hash in your controller. In the controller you can  
have some case…when logic, accessing different models = different DB  
tables. Is this what you are looking for?

Karel
