I am new to ruby and rails and am unsure how to accomplish the following: I''d like to have a page where the user enters a value in a form field and have results stream into a results div on the page. Additionally, I want to: - Not limit the result set - Allow user to get immediate feedback on what they have entered - Allow user to change field contents as results are appearing - Have query restart when field value changes Can anyone point me to an appropriate reference or suggest Rails constructs to research? Thanks in advance. -- Posted via http://www.ruby-forum.com/.
george wrote:> I am new to ruby and rails and am unsure how to accomplish the > following: > > I''d like to have a page where the user enters a value in a form field > and have results stream into a results div on the page. Additionally, I > want to: > - Not limit the result set > - Allow user to get immediate feedback on what they have entered > - Allow user to change field contents as results are appearing > - Have query restart when field value changes > > Can anyone point me to an appropriate reference or suggest Rails > constructs to research? > > Thanks in advance.Hi George Take a look at the "Agile Web development with Rails" book, there is a section about Ajax and one of its example is "Build Real-time searches with observers". Hope this helps :) Victor -- Posted via http://www.ruby-forum.com/.
> From: george <gerardgnm@gmail.com> > Subject: [Rails] real time search results > To: rails@lists.rubyonrails.org > > I am new to ruby and rails and am unsure how to accomplish the > following: > > I''d like to have a page where the user enters a value in a > form field and have results stream into a results div on the > page. Additionally, I want to: > - Not limit the result set > - Allow user to get immediate feedback on what they have entered > - Allow user to change field contents as results are appearing > - Have query restart when field value changes > > Can anyone point me to an appropriate reference or suggest > Rails constructs to research? > > Thanks in advance. >You need to use observe_field call. Check out the tutorial at http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html?page=2 Hope this helps, Bharat
I wrote a small tutorial on just this subject, that covers live search and pagination of the results. http://www.recentrambles.com/pragmatic/view/59 On Thu, 2006-06-01 at 20:40 +0530, Bharat Ahluwalia wrote:> > From: george <gerardgnm@gmail.com> > > Subject: [Rails] real time search results > > To: rails@lists.rubyonrails.org > > > > I am new to ruby and rails and am unsure how to accomplish the > > following: > > > > I''d like to have a page where the user enters a value in a > > form field and have results stream into a results div on the > > page. Additionally, I want to: > > - Not limit the result set > > - Allow user to get immediate feedback on what they have entered > > - Allow user to change field contents as results are appearing > > - Have query restart when field value changes > > > > Can anyone point me to an appropriate reference or suggest > > Rails constructs to research? > > > > Thanks in advance. > > > > You need to use observe_field call. Check out the tutorial at > http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html?page=2 > > Hope this helps, > > Bharat > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsCharlie Bowman http://www.recentrambles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060601/9ca63245/attachment.html
Victor Fan wrote:> george wrote: >> I am new to ruby and rails and am unsure how to accomplish the >> following: >> >> I''d like to have a page where the user enters a value in a form field >> and have results stream into a results div on the page. Additionally, I >> want to: >> - Not limit the result set >> - Allow user to get immediate feedback on what they have entered >> - Allow user to change field contents as results are appearing >> - Have query restart when field value changes >> >> Can anyone point me to an appropriate reference or suggest Rails >> constructs to research? >> >> Thanks in advance. > > Hi George > > Take a look at the "Agile Web development with Rails" book, there is a > section about Ajax and one of its example is "Build Real-time searches > with observers". > > Hope this helps :) > > VictorVictor, Thanks, I''ve looked at that and implemented something using this construct, but with large result sets, there is too long a delay before the data appears. And when it does, it''s all at once. I''m wanting to view in real time the data being found. A simple meaningless example would be that each record contains a number 1 to a million. When the user starts typing a 1, the results would include 1, 10-19, 21, 31, 41, etc. and would continue to be added to if the user typed nothing else. If the user adds another 1, then the results box starts over - displaying 11, 110, 111, 112, 113, etc. and again continues. Any ideas how that can be accoumplished? g g -- Posted via http://www.ruby-forum.com/.
If you''re pulling the results from a database, I''m not sure you can stream them. Database''s return the results all at once, not one at a time as it''s found. On Thu, 2006-06-01 at 18:19 +0200, george wrote:> Victor Fan wrote: > > george wrote: > >> I am new to ruby and rails and am unsure how to accomplish the > >> following: > >> > >> I''d like to have a page where the user enters a value in a form field > >> and have results stream into a results div on the page. Additionally, I > >> want to: > >> - Not limit the result set > >> - Allow user to get immediate feedback on what they have entered > >> - Allow user to change field contents as results are appearing > >> - Have query restart when field value changes > >> > >> Can anyone point me to an appropriate reference or suggest Rails > >> constructs to research? > >> > >> Thanks in advance. > > > > Hi George > > > > Take a look at the "Agile Web development with Rails" book, there is a > > section about Ajax and one of its example is "Build Real-time searches > > with observers". > > > > Hope this helps :) > > > > Victor > > Victor, > > Thanks, I''ve looked at that and implemented something using this > construct, but with large result sets, there is too long a delay before > the data appears. And when it does, it''s all at once. I''m wanting to > view in real time the data being found. A simple meaningless example > would be that each record contains a number 1 to a million. When the > user starts typing a 1, the results would include 1, 10-19, 21, 31, 41, > etc. and would continue to be added to if the user typed nothing else. > If the user adds another 1, then the results box starts over - > displaying 11, 110, 111, 112, 113, etc. and again continues. > > Any ideas how that can be accoumplished? > > g > > gCharlie Bowman http://www.recentrambles.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060601/4420dd1d/attachment.html
Charlie Bowman wrote:> If you''re pulling the results from a database, I''m not sure you can > stream them. Database''s return the results all at once, not one at a > time as it''s found. > > > On Thu, 2006-06-01 at 18:19 +0200, george wrote: > >> >> - Allow user to change field contents as results are appearing >> > section about Ajax and one of its example is "Build Real-time searches >> the data appears. And when it does, it''s all at once. I''m wanting to >> >> g > > > Charlie Bowman > http://www.recentrambles.comTrue, that gives me an idea of a few things to try. Thanks g -- Posted via http://www.ruby-forum.com/.