View: <% form_tag attendances_path, :method => ''get'' do %> <p>Search attendances by date: <%= date_select :search, params[:search], :use_short_month => true, :order => [:month, :day, :year] %> <%= submit_tag ''Search'', :name => nil %> </p> <% end %> Model: def self.search(search, page) paginate :per_page => 10, :page => page, :conditions => [''date like ?'', "%#{search}%"], :order => ''date desc'' end Controller: def index @page_title = ''Attendances'' @attendances = @school.attendances.search(params[:search], params[:page]) end Why is this not working? Thanks for any help! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Adam Cohen
2007-Aug-08 21:37 UTC
Re: Cannot get simple search by date to work with will_paginate
What isn''t working? What''s the error? What is the expected behaviour? How does the actual behaviour differ from the expected? Is it necessary for you to define a search method in your model, rather than just call @school.paginate(:all, :conditions => blah)? Adam On 8/8/07, jko170 <jko170-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > View: > > <% form_tag attendances_path, :method => ''get'' do %> > <p>Search attendances by date: > <%= date_select :search, params[:search], :use_short_month => > true, :order => [:month, :day, :year] %> > <%= submit_tag ''Search'', :name => nil %> > </p> > <% end %> > > > Model: > > def self.search(search, page) > paginate :per_page => 10, :page => page, > :conditions => [''date like ?'', "%#{search}%"], > :order => ''date desc'' > end > > > Controller: > > def index > @page_title = ''Attendances'' > @attendances = @school.attendances.search(params[:search], > params[:page]) > end > > Why is this not working? Thanks for any help! > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jko170
2007-Aug-08 23:17 UTC
Re: Cannot get simple search by date to work with will_paginate
I guess I don''t need it a search method so I added this to my controller: @attendances = @school.attendances.paginate :per_page => 10, :page => params[:page], :conditions => [''date like ?'', "%#{params[:search]}%"], :order => ''date desc'' My intended behavior is to simply search attendances by an exact date. I don''t get an error but no records show up even if I search the correct date. Also, is there a way to have a cleaner url when searching that this? domain.com/attendances?search%5B%282i%29%5D=8&search%5B%283i %29%5D=8&search%5B%281i%29%5D=2007 Thanks for the help. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jko170
2007-Aug-09 00:54 UTC
Re: Cannot get simple search by date to work with will_paginate
I really like blinksale''s invoice filter functionality. Is there a plugin for something like that? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Adam Cohen
2007-Aug-09 02:32 UTC
Re: Cannot get simple search by date to work with will_paginate
blinksale''s invoice filter looks like it''s using a bunch of custom routes and then parsing the parameters. Read up on rails routes to figure out how to implement these types of urls. And your conditions look wrong. If you''re searching by date, and the date column in your database is a date type, then you shouldn''t be using ''like''. You should be using date comparison operators, such as =, <, >, <=, >=. Adam On 8/8/07, jko170 <jko170-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I really like blinksale''s invoice filter functionality. Is there a > plugin for something like that? > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jko170
2007-Aug-09 20:22 UTC
Re: Cannot get simple search by date to work with will_paginate
Got it to work! Thanks for your help. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ratnavel Sundaramurthi
2007-Dec-05 04:37 UTC
Re: Cannot get simple search by date to work with will_pagin
jko170 wrote:> Got it to work! Thanks for your help.Hi I do face same type of issue in my project can u share how u over come that... My mail id is ratnavelps-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Thanks in advance -- 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 -~----------~----~----~----~------~----~------~--~---