Hi all, I have a question about my scope in Rails 3.0. The following code working fine but I thinks it''s not clean and could be optimzed. What do you think about that : scope :between_date, lambda { |start_at, end_at| {:conditions => ["((start_at BETWEEN ? AND ?) AND (end_at BETWEEN ? AND ?)) OR (all_day = 1 AND ((start_at BETWEEN ? AND ?) AND (end_at BETWEEN ? AND ?)))", start_at, end_at, start_at, end_at, start_at.beginning_of_day, end_at.end_of_day, start_at.beginning_of_day, end_at.end_of_day]} } (http://pastie.org/1266339) I have found the first part of the solution, but I don''t know how scope can aggragate "all_day condition" to this condition. {:conditions => { :start_at => start_at..end_at, :end_at => start_at..end_at }} Thanks for reading vincent -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.