Capturing textbox data in the same page

Hi,

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
http://railscasts.com/tags/11

Sijo Kg wrote:

Sijo Kg wrote:

I think this will help you
http://railscasts.com/tags/11

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.

VIEW

<% form_tag do %>
<%= date_select :query_date %>
<% end %>

<% if @records %>

<% for record in @records %> <% end %>
Name
<%= record.name %>
<% end %>

CONTROLLER

def view_name
if request.post?
@records = ModelName.find(:all, :conditions => [“created_on > ?”,
params[:query_date]])
end
end

On Mar 13, 11:38 pm, Dibyendu Chatterjee <rails-mailing-l…@andreas-

On 14 Mar 2008, at 08:23, Dibyendu Chatterjee wrote:

:order => [:day, :month, :year]

<% form_tag do %>
<%= date_select :“aaqq”, :order => [:day, :month, :year] %>

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)

Fred

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

On Mar 14, 10:31 pm, Frederick C. [email protected]

It did work to a lot extent. But facing problem in :
CONTROLLER :
@records = ModelName.find(:all, :conditions => [“created_on > ?”,
params[:query_date]])

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] %>

<%= submit_tag( “Display Text!” ) %>
<% end %>

<% if @records %>

<% for record in @records %> <% end %>
Name
<%= record.date %>
<% end %>

Here’s my controller code:

if request.post?
@records = WdeColumnData.find(:all, :conditions => [“date >
params[:aaqq]”])
end

Hey my code worked !! Thanx all.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs