B
Ben Simms
I'm new to RoR and I am trying to figure out how to use user input from
a text field as a parameter in a query. I know this is probably simple
but I have been messing around with it for a while and can't figuire it
out.
The controller has this method:
def search
@events = Event.find
all,
rder => 'date DESC',
:conditions => ['title=?',titleinput])
respond_to do |format|
format.html
format.xml { render :xml => @events }
end
end
and the view:
<form action='/events/search' method='post'>
<p>
<b>Title</b></br>
<input id='event_title' name='titleinput' size='30' type='text'
value=''/>
<input type='submit' value='Search'/>
</p>
</form>
I know this is probably completely wrong but I couldn't figure out how
to use the variable from the form in the query in the controller.
Thanks for any help.
Ben
a text field as a parameter in a query. I know this is probably simple
but I have been messing around with it for a while and can't figuire it
out.
The controller has this method:
def search
@events = Event.find
:conditions => ['title=?',titleinput])
respond_to do |format|
format.html
format.xml { render :xml => @events }
end
end
and the view:
<form action='/events/search' method='post'>
<p>
<b>Title</b></br>
<input id='event_title' name='titleinput' size='30' type='text'
value=''/>
<input type='submit' value='Search'/>
</p>
</form>
I know this is probably completely wrong but I couldn't figure out how
to use the variable from the form in the query in the controller.
Thanks for any help.
Ben