title: How can I do a find in Rails with conditions set on the join table of a :through association?
body: <p>I have the following models:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_many :permissions
    has_many :tasks, :through =&gt; :permissions
  
  class Task &lt; ActiveRecord::Base
    has_many :permissions
    has_many :users, :through =&gt; :permissions
  
  class Permission &lt; ActiveRecord::Base
    belongs_to :task
    belongs_to :user
  </code></pre>
  
  <p>I want to be able to display only tasks which a user has access to (i.e., the <code>read</code> flag is set to <code>true</code> in the <code>Permissions</code> table).  I can accomplish this with the following query, but it doesn't seem very Rails-y to me:</p>
  
  <pre><code>@user = current_user
  @tasks = @user.tasks.find_by_sql(["SELECT * FROM tasks INNER JOIN permissions ON tasks.id = permissions.task_id WHERE permissions.read = true AND permissions.user_id = ?", @user.id])
  </code></pre>
  
  <p>Anyone know the right way to do this?</p>