I''m using ransack for my searches. I need to search through date fields but only for year. For example I need all documents created in 2011. For those that use ransack, there such a way to do this? -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I have used ransack, but what you are looking for is not directly implemented. You have two options: 1) Use a database specific syntax such as EXTRACT 2) Create a predicate (see github readme) which will which that the date is greater then or eq to 1/1/2011 00:00:00 and less then 1/1/2012 00:00:00 You can see the built-in predicates here: https://github.com/ernie/ransack/blob/master/lib/ransack/constants.rb On Oct 19, 8:07 am, Mauro <mrsan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m using ransack for my searches. > I need to search through date fields but only for year. > For example I need all documents created in 2011. > For those that use ransack, there such a way to do this?-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 19 October 2011 17:04, PsiPro <arjesins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have used ransack, but what you are looking for is not directly > implemented. > > You have two options: > 1) Use a database specific syntax such as EXTRACTI have a form like this: = simple_form_for @q, :url => unsafe_buildings_path, :html => {:method => :get} do |f| .block .column.span-11 .inputs = f.label :practice_number_eq, t(''practice_number'') = f.input :practice_number_eq, :label => false, :required => false = f.label :property_cont, t(''property'') = f.input :property_cont, :label => false, :required => false = f.label :practice_date_in, t(''practice_date'') = f.input :practice_date_in, :as => :date, :label => false, :required => false, :start_year => Settings.unsafe_buildings_start_year, :include_blank => true = f.button :submit, "Cerca" I want to search also for practice_date where based on year. I''m using postgres as db. How can I integrate "extract" in this form? -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.