# I want to fetch the data's from the datanase. it display in

**URL:** <https://www.ruby-forum.com/t/i-want-to-fetch-the-datas-from-the-datanase-it-display-in/83868>\
**Category:** Rails\
**Created:** [January 30, 2007, 11:13am UTC](https://www.ruby-forum.com/t/i-want-to-fetch-the-datas-from-the-datanase-it-display-in/83868 "2007-01-30T11:13:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ror](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee59a6/32.png) [@ror](https://www.ruby-forum.com/u/ror)\
**Post date:** [January 30, 2007, 11:13am UTC](https://www.ruby-forum.com/t/i-want-to-fetch-the-datas-from-the-datanase-it-display-in/83868/1 "2007-01-30T11:13:43Z")

</div>

hi,

i want to fetch the data’s from the datanase. it display in combo box  
.

but i am very new to ROR. so i don’t know what are all the steps to do  
this. like where i have to put in controllter or in rhtml file.

Can any one tell step by step process, if u can. please its very  
urgent.

my database name is : panles

it contain - id,name.

combo box i want to display - panel name.

controller name is - home

rthml file is - index.rhtml

right now i have done index.rhtml only, rest i don’t know how to do

\<%=  
@panles = panel.find(:all, :panel =\> “name”)  
collection\_select(:panel, :name, @panels, :id, :name)  
%\>

but it shows the error.

please help me asap

---

<div class="post-metadata">

**Author:** ![ror](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee59a6/32.png) [@ror](https://www.ruby-forum.com/u/ror)\
**Post date:** [January 30, 2007, 11:32am UTC](https://www.ruby-forum.com/t/i-want-to-fetch-the-datas-from-the-datanase-it-display-in/83868/2 "2007-01-30T11:32:45Z")

</div>

> \<%=  
> @panles = panel.find(:all, :panel =\> “name”)  
> collection\_select(:panel, :name, @panels, :id, :name)  
> %\>  
> There are a number of problems with this code. The first thing is  
> that \<%= %\> is effectively saying ‘output everything within these  
> brackets’ - you have 2 lines of code so you’re going to get issues.

The second problem is that the line ‘@panels = …’ should be in your  
controller action:

in your controller:  
def index  
@panels = Panel.find(:all);  
end

in your view:  
\<%= collection\_select(‘panel’, ‘name’, @panels, :id, :name) %\>

For future reference, you will generally get better response if you  
post the actual error message you are receiving. I’d also recommend  
that you pick up one of the many books and tutorials that are  
available to give you a solid grounding in rails.

Steve

---

<div class="post-metadata">

**Author:** ![ror](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ee59a6/32.png) [@ror](https://www.ruby-forum.com/u/ror)\
**Post date:** [January 30, 2007, 11:59am UTC](https://www.ruby-forum.com/t/i-want-to-fetch-the-datas-from-the-datanase-it-display-in/83868/3 "2007-01-30T11:59:05Z")

</div>

hi,

Thanks a lot. i got it. and can u tell how i display using list box  
using the same table. please.

Stephen B. wrote:

> > \<%=  
> > @panles = panel.find(:all, :panel =\> “name”)  
> > collection\_select(:panel, :name, @panels, :id, :name)  
> > %\>  
> > There are a number of problems with this code. The first thing is  
> > that \<%= %\> is effectively saying ‘output everything within these  
> > brackets’ - you have 2 lines of code so you’re going to get issues.
> 
> The second problem is that the line ‘@panels = …’ should be in your  
> controller action:
> 
> in your controller:  
> def index  
> @panels = Panel.find(:all);  
> end
> 
> in your view:  
> \<%= collection\_select(‘panel’, ‘name’, @panels, :id, :name) %\>
> 
> For future reference, you will generally get better response if you  
> post the actual error message you are receiving. I’d also recommend  
> that you pick up one of the many books and tutorials that are  
> available to give you a solid grounding in rails.
> 
> Steve
