Rails 3.1.3 After watching http://railscasts.com/episodes/258-token-fields?autoplay=true I have installed the similar functionality to my app. However, def index @cities = City.all ... does in fact give the list of all cities in the text field, but def index @cities = City.where("name like ?", "%#{params[:q]}%") ... does NOT search cities at all. Since above case works (though not incremental filter), the problem must be the second query part. But I don''t see any problem in the where clause. It does not raise any errors at all. Simply, puts "No results" Can you guess where the problem is? soichi -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Fri, Nov 30, 2012 at 12:57 PM, Soichi Ishida <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> Rails 3.1.3 > > After watching > http://railscasts.com/episodes/258-token-fields?autoplay=true > I have installed the similar functionality to my app. > > However, > > def index > @cities = City.all > ... > > does in fact give the list of all cities in the text field, but > > def index > @cities = City.where("name like ?", "%#{params[:q]}%") > ... > > does NOT search cities at all. > > Since above case works (though not incremental filter), the problem must > be the second query part. > But I don''t see any problem in the where clause. It does not raise any > errors at all. Simply, puts > > "No results" >City.all returns all cities. The second query matches the city name to params[:q]. If params[:q] is empty, it will return all cities (at least that''s what I get when I tried it on the console using postgre). If it isn''t empty, it will match for cities whose names match params[:q]. If you''re using postgre, you may want to use ilike for case insensitive matching.> > Can you guess where the problem is? > > soichi > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 30 November 2012 04:57, Soichi Ishida <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Rails 3.1.3 > > After watching > http://railscasts.com/episodes/258-token-fields?autoplay=true > I have installed the similar functionality to my app. > > However, > > def index > @cities = City.all > ... > > does in fact give the list of all cities in the text field, but > > def index > @cities = City.where("name like ?", "%#{params[:q]}%") > ... > > does NOT search cities at all.If you look in log/development.log it will show you the database query being run. If you still can''t see the problem then post the section of the log for that action (including the query). Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Hi Colin, Cold you help me? I got the same error, because params[:q] is empty. How did you solve? Thanks, Ricardo. Em sexta-feira, 30 de novembro de 2012 07h15min12s UTC-2, Colin Law escreveu:> > On 30 November 2012 04:57, Soichi Ishida <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org<javascript:>> > wrote: > > Rails 3.1.3 > > > > After watching > > http://railscasts.com/episodes/258-token-fields?autoplay=true > > I have installed the similar functionality to my app. > > > > However, > > > > def index > > @cities = City.all > > ... > > > > does in fact give the list of all cities in the text field, but > > > > def index > > @cities = City.where("name like ?", "%#{params[:q]}%") > > ... > > > > does NOT search cities at all. > > If you look in log/development.log it will show you the database query > being run. If you still can''t see the problem then post the section > of the log for that action (including the query). > > Colin >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/tkML9uphpNgJ. For more options, visit https://groups.google.com/groups/opt_out.
On 10 May 2013 05:11, Ricardo do Valle <ricardodovalle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Colin, > > Cold you help me? > I got the same error, because params[:q] is empty. > How did you solve?I did not solve it, I was just suggesting the route to go to diagnose the problem. If you cannot see why params[:q] is empty then I suggest starting a new thread and explaining the problem you are having. If you are a beginner, however, then I suggest working right through a good tutorial such as railstutorial.org (which is free to use online) first in order to understand the basics of rails. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.