Capturing textbox data in the same page


I am new to ruby.
Can anyone help me with a simple code snippet where a user types in some
date in any textbox and on submission, the same page opens with expects
set of recorset in an HTML table. very urgent !

I think this will help you

Sijo Kg wrote:

I think this will help you

Sijo Kg wrote:

Sijo Kg wrote:

I think this will help you

Hey thanx Sijo. But I need a simple example in ruby.
I have a textbox, where I will fill date. And then on submission of
that, the same page gets loaded passing the value of the textbox. And at
last I need to fire some query to show relevant recordset in an HTML
table format. Please help..

First things first. You need to buy a book. Go get "Agile Web
Development With Rails"
Second things: The suggestion to go watch a few rails casts is a good
one. You should take Sijo's Advice.
Third things: here is a simple example, but You'll need to adapt it to
your situation. to do that you probably need to read your book.


It did work to a lot extent. But facing problem in :
@records = ModelName.find(:all, :conditions => ["created_on > ?",

what has to be written in : query_date.

I used :
params[:aaqq] once and then tried with
:order => [:day, :month, :year]

I failed in getting desired result.. :frowning: View C

FYI :::::

Here's my view code :

<% form_tag do %>
<%= date_select :"aaqq", :order => [:day, :month, :year] %>
<input type="text" name="txtRank">
<%= submit_tag( "Display Text!" ) %>
<% end %>

<% if @records %>
     <% for record in @records %>
       <tr><td><%= %></td></tr>
     <% end %>
<% end %>

Here's my controller code:

    @records = WdeColumnData.find(:all, :conditions => ["date >

There's 2 problems here. First of all, date_select is one of those magic helpers where the first parameter is the name of an instance variable, and the second the name of a method. It makes things easy when what you are doing is editing a date property of an activerecord object.
That's not what you're doing here though, so you should use select_date.
The second thing is that (either way) the date will get submitted as 3 separate fields (one for year, one for month, one for day), and so it needs to be turned back into an actual date serverside. If you use date_select and you assign the params to an activerecord object that will happen automatically, if you are using select_date you have to do it yourself (use Date::civil or Time.mktime)


it might help to look at the file RAILS_ROOT/logs/development.log

This file will tell you exactly what parameters are being submitted by
your form and their values so you can construct your dates from there.
Sorry about my example not working properly! haha

Hey my code worked !! Thanx all.