title: ActiveRecord: How to unscope a default_scope when using left_join?
body: <p>Let's say I have a model <code>Person</code>. This <code>Person</code> has many <code>Posts</code>. Posts have a default scope to exclude all soft-deleted entries. Soft-deleted means, that an attribute <code>deleted_at</code> is not <code>nil</code>.</p>
  
  <pre><code>class Person &lt; ActiveRecord::Base
  
    has_many :posts
  
  end
  
  class Post &lt; ActiveRecord::Base
  
    belongs_to :person
    default_scope { where(:deleted_at =&gt; nil) }
  
  end
  </code></pre>
  
  <p>I now want to query all persons who have at least one post and I want to include soft-deleted posts as well - so I want the default scope not to apply. Using</p>
  
  <pre><code>Person.left_joins(:posts).where.not(posts: { id: nil })
  </code></pre>
  
  <p>still applies the default scope and results in this SQL:</p>
  
  <pre><code>SELECT `persons`.* FROM `persons` LEFT OUTER JOIN `posts` ON `posts`.`person_id` = `persons`.`id` AND `posts`.`deleted_at` IS NULL WHERE `posts`.`id` IS NOT NULL
  </code></pre>
  
  <p>What is an elegant way to solve this?</p>