title: Help debugging my session? Rails 3 ActionDispatch::Cookies::CookieOverflow
body: <p>Even though I'm pretty sure I know why this error gets raised, I don't seem to know why or how my session is exceeding the 4KB limit...</p>
  
  <p>My app was working fine, but once I deliberately started adding bugs to see if my transactions were rolling back I started getting this error.</p>
  
  <p>To give some background, I'm busy coding a tournament application that (in this section) will create the tournament and then add some tournament legs based on the number of teams as well as populate the the tournament with some 'ghost fixtures' once the legs have been created.</p>
  
  <p>The flash[:tournament] was working correctly before; using a tournament object, I have access to any AR validation errors as well as data that has been entered on the previous page to create the tournament.</p>
  
  <p><em>TournamentController.rb</em></p>
  
  <pre><code>begin
    &lt;other code&gt;
    Tournament.transaction do
      tournament.save!
      Tournament.generate_legs tournament
      Tournament.generate_ghost_fixtures tournament
    end
  
    flash[:notice] = "Tournament created!"
    redirect_to :action =&gt; :index
  rescue Exception =&gt; e
    flash[:tournament] = tournament
    redirect_to :action =&gt; :new, :notice =&gt; "There was an error!"
  end
  </code></pre>
  
  <p><em>Tournament.rb</em></p>
  
  <pre><code>self.generate_ghost_fixtures(tournament)
    &lt;other code&gt;
    #Generate the ghost fixtures
    #tournament_legs is a has_many association
    tournament_legs_array = tournament.tournament_legs
  
    tournament_legs_array.each do |leg|
      number_of_fixtures = matches[leg.leg_code]
  
      #For the first round of a 32 team tournament, this block will run 16 times to create the matches
      number_of_fixtures.times do |n|
        Fixture.creatse!(:tournament_leg_id =&gt; leg.id, :match_code =&gt; "#{leg.leg_code}-#{n+1}")
      end
    end
  end
  </code></pre>
  
  <p>I can do nothing but speculate as to why my session variable is exceeding 4KB??
  Is it possible that the tournament object I pass through the flash variable contains all the associations as well?</p>
  
  <p>Here is the dump of my session once I get the error.</p>
  
  <p>Hope this is enough info to help me out :)</p>
  
  <p>Thanks</p>
  
  <p><em>Session Dump</em></p>
  
  <pre><code>_csrf_token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  flash: {:tournament=&gt;#&lt;Tournament id: nil, tournament_name: "asd", tournament_description: "asdasd", game_id: 1, number_of_teams: 16, start_date: "2011-04-30 00:00:00", tournament_style: "single elimination", tournament_status: "Drafting", active: true, created_at: "2011-04-30 10:07:28", updated_at: "2011-04-30 10:07:28"&gt;}
  player_id: 1
  session_id: "4e5119cbaee3d5d09111f49cf47aa8fa"
  </code></pre>