title: In rails how can I delegate to a class method
body: <pre class="lang-rb prettyprint-override"><code>class Task &lt; ActiveRecord::Base
    attr_accessible :due_date, :text
  
    def self.this_week
      where(:due_date =&gt; Date.today.beginning_of_week..Date.today.end_of_week)
    end
  end
  
  class Important &lt; ActiveRecord::Base
    attr_accessible :email
  
    has_one :task, :as =&gt; :taskable, :dependent =&gt; :destroy
  
    delegate this_week, :to =&gt; :task
  end
  </code></pre>
  
  <p>So far this delegate is not working as expected, when I try <code>Important.this_week</code>.  I get an error saying there is no method <code>this_week</code> defined for class...</p>
  
  <p>Any ideas? Can I even delegate to a class method like this?  I may have another class or two extending <code>Task</code> in this way, so I'm curious how this works in a way that doesn't duplicate a bunch of code to each implementing class.</p>