title: How to use around_filter to scope all queries in Rails?
body: <p><strong>My Problem</strong><br>
  We are developing a locally-hosted web application for small businesses. We also have a demo site that lets potential customers look around to evaluate the product. Right now, all customers using the demo site have access to the same data, which is less than ideal because they might be making modifications behind each others backs, which would make the app feel "unstable" if they noticed. I would like to give each customer their own data subset to improve their experience. Adding a user_id column to all my models is easy enough, but now I need to make sure all the queries use this new association.</p>
  
  <p><strong>The Hard Way of Solving My Problem</strong><br>
  I could go through by hand and change a call like <code>@people = Person.all</code> to <code>@people = current_user.people</code>, but lame! Development is continuing on the master branch, and I don't want to have to babysit every query when I merge over to the demo branch.</p>
  
  <p><strong>What I'd Like to do Instead</strong><br>
  I would like to do create an around_filter in my application_controller that will grab my queries and add in this extra layer of scoping like so:</p>
  
  <pre>around_filter :scope_on_current_user
  
  def scope_on_current_user(&block)
    MagicalClass.scope_on_user(current_user, &bock)
  end</pre>
  
  <p>This is an idea I got from <a href="https://github.com/tchandy/octopus" rel="nofollow">octopus</a>, which is a database sharding gem. I've looked around in their source code, and it looks pretty hairy. They pretty much go elbow-deep into ActiveRecord, hijacking the DB connection, etc. I'm hoping that is overkill for what I want. Any advice on how <code>MagicalClass</code> might work? :)  </p>
  
  <p>Rails 3.1.0<br>
  ActiveRecord 3.1.0</p>