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 ! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think this will help you -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sijo Kg wrote:> I think this will help youhttp://railscasts.com/tags/11 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sijo Kg wrote:> Sijo Kg wrote: >> I think this will help you > http://railscasts.com/tags/11Hey 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.. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 %> <table> <tr><th>Name</th></tr> <% for record in @records %> <tr><td><%= record.name %></td></tr> <% end %> </table> <% 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- s.net> wrote:> 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.. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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.. :( 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 %> <table> <tr><th>Name</th></tr> <% for record in @records %> <tr><td><%= record.date %></td></tr> <% end %> </table> <% end %> Here''s my controller code: if request.post? @records = WdeColumnData.find(:all, :conditions => ["date > params[:aaqq]"]) end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 14 Mar 2008, at 08:23, Dibyendu Chatterjee wrote:> > 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] > > <% form_tag do %> > <%= date_select :"aaqq", :order => [:day, :month, :year] %> > <input type="text" name="txtRank">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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 14 Mar 2008, at 08:23, Dibyendu Chatterjee wrote: > > > > > 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] > > > <% form_tag do %> > > <%= date_select :"aaqq", :order => [:day, :month, :year] %> > > <input type="text" name="txtRank"> > > 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey my code worked !! Thanx all. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---