title: Rails: Defining methods for my controllers
body: <p>Newbie question! I'm trying to get my head around how I can set up specific Active Record searches which I then call from my controllers. Why is this throwing an undefined method error?</p>
  
  <p><strong>method defined in the Model:</strong></p>
  
  <pre><code>class Event &lt; ActiveRecord::Base
  
      attr_accessible :category, :date_end, :date_start, :description, :time_start, :title, :venue, :image
  
  
      def next_seven_days
          t = Time.now
          Event.where("date_end BETWEEN ? AND ?", t, t+7.days).order("date_end ASC")
      end
  end
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>def index
      @events = Event.next_seven_days     
  end
  </code></pre>