title: Where to store value for duration of request
body: <h2>Preamble</h2>
  
  <p>I'm developing a card game server in Rails. The application records what a player is expected to do via a tree of instances of the <code>PendingAction</code> model. </p>
  
  <pre><code>class Player &lt; ActiveRecord::Base
    has_many :cards
    has_many :pending_actions
  end
  </code></pre>
  
  <p>At any time, the player needs to act on any leaf <code>PendingAction</code>s - there may be more than one, for instance:</p>
  
  <pre><code>1. End turn
  |
  +- 2. Do thing A
  |  |
  |  + 3. Do thing pre-A
  |
  +- 4. Do thing B
     |
     + 5. Do thing pre-B
  </code></pre>
  
  <p>The view code presents the player with one or more forms, requesting their choice for each leaf action. For instance, in the above case, forms would be presented to solicit input for actions 3 and 5.</p>
  
  <p>When the player makes a choice for, say, action 5, that action is destroyed. However, processing their choice may cause them to need to make another choice before the parent (action 4) can happen. Like so:</p>
  
  <pre><code>1. End turn
  |
  +- 2. Do thing A
  |  |
  |  + 3. Do thing pre-A
  |
  +- 4. Do thing B
     |
     + 6. Do other thing pre-B
  </code></pre>
  
  <p>Action 4 therefore needs to be on-hand, so action 6 can be created as its child. At present, I am simply passing action 4 around as a function argument. However, I've just come across a situation where it would really help to be able to have access to it in a <code>before_save</code> hook on a <code>Card</code> object.</p>
  
  <h2>Question</h2>
  
  <p>Where is the best place to store an object, associated with a <code>Player</code>, that I can access from all models related to that <code>Player</code>, which is valid throughout - but not beyond - a single HTTP request?</p>
  
  <p>I am running under Heroku, with 1 dyno - so I believe I'm single-threaded.</p>