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

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

<%=
@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

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