I am a newbie and have created a small blog-like app. Im have tried to implement the saerch function following this tutorial: http://snippets.dzone.com/posts/show/1691 Everything seems to work when the searchphase is empty (it finds the 454 rows) but as soon as I start typing it returns nothing. Here is the controller: def live_search @phrase = request.raw_post || request.query_string a1 = "%" a2 = "%" @searchphrase = a1 + @phrase + a2 @results = Funktioner.find(:all, :conditions => [ "Description LIKE ?", @searchphrase]) @number_match = @results.length render(:layout => false) end The Description-column is text rich and contains the word ledelse, but when searched it returns: ''ledelse='' not found! One of the puzzels is where the equal sign comes from. It appears also in the logging og the mysql queries. Can you help me - anyone? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What does p @phrase return if you do it prior to the query line p @phrase @results = Funktioner.find(:all, :conditions => [ "Description LIKE ?", @searchphrase]) Also what about @searchphrase = "%#{@phrase}%" arbirk wrote:> I am a newbie and have created a small blog-like app. Im have tried to > implement the saerch function following this tutorial: > http://snippets.dzone.com/posts/show/1691 > > Everything seems to work when the searchphase is empty (it finds the > 454 rows) but as soon as I start typing it returns nothing. Here is > the controller: > > def live_search > > @phrase = request.raw_post || request.query_string > a1 = "%" > a2 = "%" > @searchphrase = a1 + @phrase + a2 > @results = Funktioner.find(:all, :conditions => [ "Description > LIKE ?", @searchphrase]) > > @number_match = @results.length > > render(:layout => false) > end > > The Description-column is text rich and contains the word ledelse, but > when searched it returns: > ''ledelse='' not found! > > One of the puzzels is where the equal sign comes from. It appears also > in the logging og the mysql queries. > > Can you help me - anyone?-- 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 -~----------~----~----~----~------~----~------~--~---
arbirk wrote:> I am a newbie and have created a small blog-like app. Im have tried to > implement the saerch function following this tutorial: > http://snippets.dzone.com/posts/show/1691 > > Everything seems to work when the searchphase is empty (it finds the > 454 rows) but as soon as I start typing it returns nothing. Here is > the controller: > > def live_search > > @phrase = request.raw_post || request.query_string > a1 = "%" > a2 = "%" > @searchphrase = a1 + @phrase + a2 > @results = Funktioner.find(:all, :conditions => [ "Description > LIKE ?", @searchphrase]) > > @number_match = @results.length > > render(:layout => false) > end > > The Description-column is text rich and contains the word ledelse, but > when searched it returns: > ''ledelse='' not found! > > One of the puzzels is where the equal sign comes from. It appears also > in the logging og the mysql queries. > > Can you help me - anyone?I think your problem is that later Prototypes always try to encode a key=value query string, which doesn''t work with request.raw_post. So add the option :with => ''phrase'' to your observe_field options, and in your controller have @phrase = params[:phrase] -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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 worked like a charm! Thanks to both of you for your quick response Best, David On Jun 25, 7:48 pm, Mark Reginald James <m...-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> arbirk wrote: > > I am a newbie and have created a small blog-like app. Im have tried to > > implement the saerch function following this tutorial: > >http://snippets.dzone.com/posts/show/1691 > > > Everything seems to work when the searchphase is empty (it finds the > > 454 rows) but as soon as I start typing it returns nothing. Here is > > the controller: > > > def live_search > > > @phrase = request.raw_post || request.query_string > > a1 = "%" > > a2 = "%" > > @searchphrase = a1 + @phrase + a2 > > @results = Funktioner.find(:all, :conditions => [ "Description > > LIKE ?", @searchphrase]) > > > @number_match = @results.length > > > render(:layout => false) > > end > > > The Description-column is text rich and contains the word ledelse, but > > when searched it returns: > > ''ledelse='' not found! > > > One of the puzzels is where the equal sign comes from. It appears also > > in the logging og the mysql queries. > > > Can you help me - anyone? > > I think your problem is that later Prototypes always try to > encode a key=value query string, which doesn''t work with > request.raw_post. > > So add the option > > :with => ''phrase'' > > to your observe_field options, and in your controller have > > @phrase = params[:phrase] > > -- > We develop, watch us RoR, in numbers too big to ignore.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---