# Accessing data in a separate table w/out relationship

**URL:** <https://www.ruby-forum.com/t/accessing-data-in-a-separate-table-w-out-relationship/69159>\
**Category:** Rails\
**Created:** [September 19, 2006, 1:59am UTC](https://www.ruby-forum.com/t/accessing-data-in-a-separate-table-w-out-relationship/69159 "2006-09-19T01:59:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![subatomic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@subatomic](https://www.ruby-forum.com/u/subatomic)\
**Post date:** [September 19, 2006, 1:59am UTC](https://www.ruby-forum.com/t/accessing-data-in-a-separate-table-w-out-relationship/69159/1 "2006-09-19T01:59:16Z")

</div>

This question has two parts

1. I currently have setup two models and 1 controller. In the view of  
the controller I have setup a form with a select form component and  
would like the values of this select component to be filled with ALL  
values of a particular component in the colum of the second model.

Example-

Table 1: id name comment  
Table 2: id comment

I do not want to use any relationship (as in has\_many, etc.) here  
because I hope in the future to allow the user to be able to add their  
own comment if they do not find a comment in the select component that  
they like. Can this be done without explicity stating SQL in the  
find\_by\_sql command.

Thanks,  
Benjamin

---

<div class="post-metadata">

**Author:** ![subatomic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@subatomic](https://www.ruby-forum.com/u/subatomic)\
**Post date:** [September 19, 2006, 5:23am UTC](https://www.ruby-forum.com/t/accessing-data-in-a-separate-table-w-out-relationship/69159/2 "2006-09-19T05:23:55Z")

</div>

On 9/19/06, Benjamin H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Table 1: id name comment

Acts\_as\_dropdown may be what you want:

[http://delynnberry.com/pages/acts\_as\_dropdown/](http://delynnberry.com/pages/acts_as_dropdown/)

Cheers,  
Max

---

<div class="post-metadata">

**Author:** ![subatomic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@subatomic](https://www.ruby-forum.com/u/subatomic)\
**Post date:** [September 19, 2006, 5:57am UTC](https://www.ruby-forum.com/t/accessing-data-in-a-separate-table-w-out-relationship/69159/3 "2006-09-19T05:57:17Z")

</div>

I’d rather not use a plugin. Are there any work-arounds?

---

<div class="post-metadata">

**Author:** ![subatomic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@subatomic](https://www.ruby-forum.com/u/subatomic)\
**Post date:** [September 19, 2006, 6:54am UTC](https://www.ruby-forum.com/t/accessing-data-in-a-separate-table-w-out-relationship/69159/4 "2006-09-19T06:54:02Z")

</div>

On 9/19/06, Benjamin H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’d rather not use a plugin. Are there any work-arounds?
> 
> –

Use

\<%= collection\_select ‘model\_1\_name’, ‘comment’, Comment.find(:all),  
‘id’, ‘name’ %\>

and read up here:

[http://wiki.rubyonrails.org/rails/pages/HowtoUseFormOptionHelpers](http://wiki.rubyonrails.org/rails/pages/HowtoUseFormOptionHelpers)

Cheers,  
Max

---

<div class="post-metadata">

**Author:** ![subatomic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@subatomic](https://www.ruby-forum.com/u/subatomic)\
**Post date:** [September 19, 2006, 7:00am UTC](https://www.ruby-forum.com/t/accessing-data-in-a-separate-table-w-out-relationship/69159/5 "2006-09-19T07:00:28Z")

</div>

Max M. wrote:

> On 9/19/06, Benjamin H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I’d rather not use a plugin. Are there any work-arounds?
> > 
> > –
> 
> Use
> 
> \<%= collection\_select ‘model\_1\_name’, ‘comment’, Comment.find(:all),  
> ‘id’, ‘name’ %\>
> 
> and read up here:
> 
> [http://wiki.rubyonrails.org/rails/pages/HowtoUseFormOptionHelpers](http://wiki.rubyonrails.org/rails/pages/HowtoUseFormOptionHelpers)
> 
> Cheers,  
> Max

Thanks
