Here's a simplification -> http://gist.github.com/129084
You're not using this sort_by "all" for anything in this code, why is it in there? The named scope thing you'll see in the code is explained here - http://ryandaigle.com/articles/2008/3/24/what-s-new-in-edge-rails-has-finder-functionality - Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Sat, Jun 13, 2009 at 12:21 AM, Älphä Blüë<[email protected]> wrote: > > Marnen, good advice. > > Something like this: > > def self.do_sort(sort_by, search, page) > start_date = Time.now.beginning_of_week > end_date = Time.now.end_of_week > page_returns = {:conditions => ['compiled_on > ? and compiled_on < > ?', start_date, end_date], > :conditions => ['name like ?', "%#{search}%"], > :order => 'rank'} > if (sort_by != "all") then > paginate(page_returns.merge({ :per_page => 20, :page => page })) > else > paginate(page_returns.merge({ :per_page => 120, :page => page })) > end > end > -- > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

