title: Rails - retrieve result of method call from controller in a different model
body: <p>I'm trying to make a call to my json end point to give me back all the Assignments WHERE the volunteer_shift.date is between params[:start] and params[:end]</p>
  <p>Is there a way I can do that in the index method of assignments_controller?</p>
  <p>I currently have this in the index method of my controller but it is exploding in my face...</p>
  <p>assignments_controller.rb</p>
  <pre><code>def index
    @assignments = Assignment.where(volunteer_shift.date: params[:start]..params[:end])  &lt;--- HOW To DO this?
  end
  </code></pre>
  <p>Here is what my assignments model looks like...</p>
  <p>assignment.rb</p>
  <pre><code>class Assignment &lt; ApplicationRecord
    belongs_to :volunteer_shift
  
    def event_date
      self.volunteer_shift.date
    end
  ...
  end
  </code></pre>
  <p>In my Volunteer_shift model I have a &quot;date&quot; method</p>
  <p>volunteer_shift.rb</p>
  <pre><code>class VolunteerShift &lt; ApplicationRecord
    has_many :assignments
    belongs_to :volunteer_event
  ...
    def date
      self.volunteer_event.date
    end
  end
  </code></pre>
  <p>is there a way I can get back all the Assignments WHERE the volunteer_shift.date (or assignment.event_date) is between params[:start] and params[:end]?</p>
  <p>Note: Rails 5</p>