# Oracle adapter + activerecord sessions do not work

**URL:** <https://www.ruby-forum.com/t/oracle-adapter-activerecord-sessions-do-not-work/125053>\
**Category:** Rails\
**Created:** [January 4, 2008, 9:40pm UTC](https://www.ruby-forum.com/t/oracle-adapter-activerecord-sessions-do-not-work/125053 "2008-01-04T21:40:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [January 4, 2008, 9:40pm UTC](https://www.ruby-forum.com/t/oracle-adapter-activerecord-sessions-do-not-work/125053/1 "2008-01-04T21:40:54Z")

</div>

Anyone know what’s up with the activerecord session store when using  
the oracle adapter in Rails 2.0.2 ?

I can set a session variable and can then see it’s actually set using  
the debugger, but after the request completes the session is empty  
(the @data member is nil). The session\_id is staying the same and the  
updated\_at field is being updated but nothing I put in a session makes  
it to the end of a request.

It’s also worth mentioning the oracle adapter wouldn’t work for me at  
all until I found this patch code which provides the select\_rows  
method, seems they forgot to implement it or something:

require ‘active\_record/connection\_adapters/oracle\_adapter’  
module ActiveRecord  
module ConnectionAdapters  
class OracleAdapter  
def select\_rows(sql, name = nil)  
@connection.query\_with\_result = true  
result = execute(sql, name)  
rows = []  
result.each { |row| rows \<\< row }  
result.free  
rows  
end  
end  
end  
end

I placed that in environment.rb and it works best I can tell but now I  
find my active record sessions are broken. I’m not sure if the two  
problems are related.

The default cookie sessions work without an issues.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [January 15, 2008, 6:46pm UTC](https://www.ruby-forum.com/t/oracle-adapter-activerecord-sessions-do-not-work/125053/2 "2008-01-15T18:46:27Z")

</div>

Greg,  
I ran into the same problem. I found the solution here:  
[http://blog.rayapps.com/2008/01/08/fix-for-rails-20-on-oracle-with-database-session-store/](http://blog.rayapps.com/2008/01/08/fix-for-rails-20-on-oracle-with-database-session-store/)

Basically because the session data is stored in a CLOB you need to  
include this in your environment.rb

class CGI::Session::ActiveRecordStore::Session  
after\_save :write\_lobs  
end

-Paul

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [January 15, 2008, 9:44pm UTC](https://www.ruby-forum.com/t/oracle-adapter-activerecord-sessions-do-not-work/125053/3 "2008-01-15T21:44:35Z")

</div>

On 1/15/08, paul damer [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> end  
> Thanks. I’ll give it a try.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)
