title: How to use unscoped on associated relations in Rails3?
body: <p>I have a default scope on products due to information security constraints.</p>
  
  <pre><code>class Product &lt; ActiveRecord::Base
    has_many :photos
  
    default_scope where('visible = 1')
  end
  </code></pre>
  
  <p>In my associated Photo model, however, I also have to find products that should not be visible.</p>
  
  <pre><code>class Photo &lt; ActiveRecord::Base
    belongs_to :product
  end
  
  my_photo.product
  </code></pre>
  
  <p>In other cases, I can use <a href="http://apidock.com/rails/ActiveRecord/Base/unscoped/class?q=unscoped" rel="noreferrer">unscoped</a> in order to bypass the default_scope, e.g. in <code>Product.unscoped.find_by_title('abc')</code>. However:</p>
  
  <p><strong>How to remove the scope when using associations of a record?</strong></p>
  
  <p><code>my_photo.unscoped.product</code> does not make sense as my_photo does not have a method called <code>unscoped</code>. Neither does <code>my_photo.product.unscoped</code> make sense as <code>my_photo.product</code> may already be nil.</p>