Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > d51872cc0e1fdee944d71993f94ac764 > files > 715

ruby-activerecord-2.3.4-1mdv2010.0.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveRecord::SessionStore</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveRecord::SessionStore</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/lib/active_record/session_store_rb.html">
                lib/active_record/session_store.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                ActionController::Session::AbstractStore
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
A session store backed by an Active Record class. A default class is
provided, but any object duck-typing to an Active Record <a
href="SessionStore/Session.html">Session</a> class with text
<tt>session_id</tt> and <tt>data</tt> attributes is sufficient.
</p>
<p>
The default assumes a <tt>sessions</tt> tables with columns:
</p>
<pre>
  +id+ (numeric primary key),
  +session_id+ (text, or longtext if your session data exceeds 65K), and
  +data+ (text or longtext; careful if your session data exceeds 65KB).
</pre>
<p>
The <tt>session_id</tt> column should always be indexed for speedy lookups.
<a href="SessionStore/Session.html">Session</a> data is marshaled to the
<tt>data</tt> column in Base64 format. If the data you write is larger than
the column&#8216;s size limit, ActionController::SessionOverflowError will
be raised.
</p>
<p>
You may configure the table name, primary key, and data column. For
example, at the end of <tt>config/environment.rb</tt>:
</p>
<pre>
  ActiveRecord::SessionStore::Session.table_name = 'legacy_session_table'
  ActiveRecord::SessionStore::Session.primary_key = 'session_id'
  ActiveRecord::SessionStore::Session.data_column_name = 'legacy_session_data'
</pre>
<p>
Note that setting the primary key to the <tt>session_id</tt> frees you from
having a separate <tt>id</tt> column if you don&#8216;t want it. However,
you must set <tt>session.model.id = session.session_id</tt> by hand! A
before filter on ApplicationController is a good place.
</p>
<p>
Since the default class is a simple Active Record, you get timestamps for
free if you add <tt>created_at</tt> and <tt>updated_at</tt> datetime
columns to the <tt>sessions</tt> table, making periodic session expiration
a snap.
</p>
<p>
You may provide your own session class implementation, whether a
feature-packed Active Record or a bare-metal high-performance SQL store, by
setting
</p>
<pre>
  ActiveRecord::SessionStore.session_class = MySessionClass
</pre>
<p>
You must implement these methods:
</p>
<pre>
  self.find_by_session_id(session_id)
  initialize(hash_of_session_id_and_data)
  attr_reader :session_id
  attr_accessor :data
  save
  destroy
</pre>
<p>
The example <a href="SessionStore/SqlBypass.html">SqlBypass</a> class is a
generic SQL session store. You may use it as a basis for high-performance
database-specific stores.
</p>

    </div>


   </div>


  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Class <a href="SessionStore/Session.html" class="link">ActiveRecord::SessionStore::Session</a><br />
Class <a href="SessionStore/SqlBypass.html" class="link">ActiveRecord::SessionStore::SqlBypass</a><br />

    </div>

    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">SESSION_RECORD_KEY</td>
          <td>=</td>
          <td class="context-item-value">'rack.session.record'.freeze</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>