I will have roughly 37 models that will contain this piece of code
(although it will be further modified):

  def self.search(search, page)
    start_date = Time.now.beginning_of_week
    end_date = Time.now.end_of_week
    paginate :per_page => 10, :page => page,
      :conditions => ['compiled_on > ? and compiled_on < ?', start_date,
end_date],
      :conditions => ['name like ?', "%#{search}%"],
      :order => 'rank'
  end

It defines pagination using will_paginate.

The question I have is how can I simplify this by creating a
global/helper class that can be used in the other 37 pages.  I'm still
very newbish but I'm really trying to learn best practice concepts so my
cleanup process is DRY as I develop.

Many thanks..
-- 
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to