title: rails find_or_create_by creates duplicates
body: <p>For some reason the below code creates duplicates. It doesn't happen always. If I refresh enough times it stops happening. The strange thing is that the "duplicate" it's creating doesn't even match my user id! This is in dev. The User table doesn't even have a user with an id = 1.</p>
  
  <pre><code>@food.page_views.find_or_create_by_user_id(current_user)
  </code></pre>
  
  <p>here's my current_user method.</p>
  
  <pre><code>def current_user
    @current_user ||= User.find(session[:user_id]) if session[:user_id]
    rescue ActiveRecord::RecordNotFound
      session[:user_id] = nil
    end
    helper_method :current_user
  end
  </code></pre>
  
  <p>from console:</p>
  
  <pre><code>PageView Load (0.4ms)  SELECT "page_views".* FROM "page_views" WHERE "page_views"."food_id" = 2 AND "page_views"."user_id" = 3 LIMIT 1
  (4.0ms)  BEGIN
  SQL (0.6ms)  INSERT INTO "page_views" ("created_at", "food_id", "updated_at", "user_id") VALUES ($1, $2, $3, $4) RETURNING "id"  [["created_at", Tue, 25 Sep 2012 01:36:43 UTC +00:00], ["food_id", 2], ["updated_at", Tue, 25 Sep 2012 01:36:43 UTC +00:00], ["user_id", 1]]
  </code></pre>