This whole "sort_by" thing isn't really nice, bad naming and an even worse condition, here's how you can avoid this if and even improve the method name that says nothing about what's being searched.
http://gist.github.com/129084 - Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Sat, Jun 13, 2009 at 10:19 AM, Älphä Blüë<[email protected]> wrote: > > Okay here's what I did and yes, it's a lot shorter (thanks!): > > named_scope :compiled_this_week, lambda { { :conditions => > ['compiled_on > ? and compiled_on < ?', Time.now.beginning_of_week, > Time.now.end_of_week] } } > > def self.do_sort(sort_by, search, page) > (sort_by == "all") ? numpages = 120 : numpages = 20 > compiled_this_week.paginate( :conditions => ['name like ?', > "%#{search}%"], :order => 'rank', :per_page => numpages, :page => page ) > 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 -~----------~----~----~----~------~----~------~--~---

