# Switching to active\_record\_store session management errors out

**URL:** <https://www.ruby-forum.com/t/switching-to-active-record-store-session-management-errors-out/156346>\
**Category:** Rails\
**Created:** [December 25, 2008, 5:35am UTC](https://www.ruby-forum.com/t/switching-to-active-record-store-session-management-errors-out/156346 "2008-12-25T05:35:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pepe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/4da419/32.png) [@pepe](https://www.ruby-forum.com/u/pepe)\
**Post date:** [December 25, 2008, 5:35am UTC](https://www.ruby-forum.com/t/switching-to-active-record-store-session-management-errors-out/156346/1 "2008-12-25T05:35:48Z")

</div>

Hello,

Running Ruby 1.8.6 and Rails 2.2.2 against an Oracle XE database  
(sigh).

I just upgraded Rails from 1.2.3 to 2.2.2, which made my cookie based  
system for storing session information to error out due to the 4Kb  
limit. So, I tried to turn on the active\_record\_store system by un-  
commenting out the “config.action\_controller.session\_store  
= :active\_record\_store” line in environment.rb and then create a db  
session (db:sessions:create) and run a rake migration (rake  
db:migrate).

Got all that done, which created a table named SESSIONS in the DB.  
However I had to tweak the migration code because the table name  
generated was singular (SESSION) and Oracle didn’t like that name. I  
searched the internet and found a sample where the table name was  
plural (SESSIONS), so I made the change hoping for the best. Here is  
the SQL generated:

CREATE TABLE “SESSIONS”  
( “ID” NUMBER(38,0) NOT NULL ENABLE,  
“SESSION\_ID” VARCHAR2(255) NOT NULL ENABLE,  
“DATA” CLOB,  
“CREATED\_AT” DATE,  
“UPDATED\_AT” DATE,  
PRIMARY KEY (“ID”) ENABLE  
)  
/

CREATE INDEX “INDEX\_SESSIONS\_ON\_SESSION\_ID” ON  
“SESSIONS” (“SESSION\_ID”)  
/

CREATE INDEX “INDEX\_SESSIONS\_ON\_UPDATED\_AT” ON  
“SESSIONS” (“UPDATED\_AT”)  
/

But now, when I try to start my application, I get an error I’ve been  
unable to solve. This is the error:

/!\ FAILSAFE /!\ Wed Dec 24 22:36:41 -0500 2008  
Status: 500 Internal Server Error  
“DESC session” failed; does it exist?  
(eval):3:in ‘describe’  
c:/ruby/lib/ruby/gems/1.8./gems/activerecord-oracle-adapter01.0.0.9250/  
lib/active\_record/connection\_adapters/oracle\_adapter.rb:334: in  
‘columns’

And here are the first 2 lines of the method:

```
    def columns(table_name, name = nil) #:nodoc:
      (owner, table_name) = @connection.describe(table_name)

```

I believe the problem is in the table name change I made (from  
singular to plural). I have looked to see if there was a way in Rails  
to override the name of the table that stores session information but  
couldn’t find any.

I really would appreciate some help on this.

Thanks in advance.

Pepe

---

<div class="post-metadata">

**Author:** ![pepe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/4da419/32.png) [@pepe](https://www.ruby-forum.com/u/pepe)\
**Post date:** [December 25, 2008, 2:49pm UTC](https://www.ruby-forum.com/t/switching-to-active-record-store-session-management-errors-out/156346/2 "2008-12-25T14:49:40Z")

</div>

I want to thank whoever sent me the answer below to my e-mail address.  
I tried to answer the e-mail but the e-mail server returned the e-mail  
saying the address didn’t exist.

This did the trick, but it sparkled another question. I tried to dig  
through the Rails and Ruby documentations to get to the class where  
the ‘magic’ happens and I am too dense to figure out where it is. I  
would appreciate if somebody shed some light on how to get there.

Thanks a lot.

Pepe

```
# You may configure the table name, primary key, and data column.
# For example, at the end of <tt>config/environment.rb</tt>:
# CGI::Session::ActiveRecordStore::Session.table_name =

```

‘legacy\_session\_table’  
# CGI::Session::ActiveRecordStore::Session.primary\_key =  
‘session\_id’  
# CGI::Session::ActiveRecordStore::Session.data\_column\_name =  
‘legacy\_session\_data’  
# Note that setting the primary key to the +session\_id+ frees you  
from  
# having a separate +id+ column if you don’t want it. However,  
you must  
# set session.model.id = session.session\_id by hand! A  
before filter  
# on ApplicationController is a good place.

/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action\_controller/  
session/active\_record\_store.rb

---

<div class="post-metadata">

**Author:** ![pepe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/4da419/32.png) [@pepe](https://www.ruby-forum.com/u/pepe)\
**Post date:** [December 25, 2008, 4:18pm UTC](https://www.ruby-forum.com/t/switching-to-active-record-store-session-management-errors-out/156346/3 "2008-12-25T16:18:04Z")

</div>

“You may configure the table name, primary key, and data column.  
For example, at the end of config/environment.rb:  
CGI::Session::ActiveRecordStore::Session.table\_name =  
‘legacy\_session\_table’  
CGI::Session::ActiveRecordStore::Session.primary\_key = ‘session\_id’  
CGI::Session::ActiveRecordStore::Session.data\_column\_name =  
‘legacy\_session\_data’  
Note that setting the primary key to the +session\_id+ frees you from  
having a separate +id+ column if you don’t want it. However, you must  
session.model.id = session.session\_id by hand! A before  
filter  
on ApplicationController is a good place.”

/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action\_controller/  
session/active\_record\_store.rb
