# Session access

**URL:** <https://www.ruby-forum.com/t/session-access/91727>\
**Category:** Rails\
**Created:** [April 11, 2007, 10:24pm UTC](https://www.ruby-forum.com/t/session-access/91727 "2007-04-11T22:24:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![caefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e36b37/32.png) [@caefer](https://www.ruby-forum.com/u/caefer)\
**Post date:** [April 11, 2007, 10:24pm UTC](https://www.ruby-forum.com/t/session-access/91727/1 "2007-04-11T22:24:26Z")

</div>

Hi Folks,

IÂ´m currently implementing a scaffold (activescaffold) based RoR  
application.

So I have something like this:

class MyController \< ApplicationController  
active\_scaffold :my\_model  
end

Now I want to do something more dynamic:

class MyController \< ApplicationController  
DynamicModel = Class.new(ActiveRecord::Base) {  
set\_table\_name = “DynamicTableName”  
}

active\_scaffold DynamicModel  
end

This works pretty good. When I set a “DynamicTableName” to a real table  
name I get the scaffolded list view like expected. But as  
“DynamicTableName” says it should be dynamic, I want to do something  
like: pass the table name from one controller to the dynamic controller  
via request params or session so it sets the table name on the fly.

But it seems, that I donÂ´t have full access to the request params or the  
session in the state that the controller is in while doing scaffolding  
things. Especially request params donÂ´t look pretty useful here. But  
what about the session?

When in the scaffolding part “session.inspect” returns something like:  
Session: [{:session\_key=\>"\_Test\_session\_id"}, {}] (This comes from  
ApplicationController directly)

But when in an instance method like “index” I get this:  
Session: #\<CGI::Session:0x47d2d4c  
@dbman=#\<CGI::Session::PStore:0x47d2b30  
@hash={:dynamic\_table\_name=\>“MyTable”, “flash”=\>{}},  
@p=#\<PStore:0x47cd9dc  
@filename=“D:/IDE/eclipse3.2.2/workspace/Test\_1/config/…/tmp/sessions//ruby\_sess.65f3543af8286132”,  
@table=nil, @transaction=false, @abort=false, @rdonly=false\>\>,  
@new\_session=true, @write\_lock=true,  
@session\_id=“2f20c4126de1c3e23a1687586134512e”,  
@data={:test\_key=\>“test\_val”, “flash”=\>{}},  
@dbprot=[#\<CGI::Session::PStore:0x47d2b30 @hash={:test\_key=\>“test\_val”,  
“flash”=\>{}}, @p=#\<PStore:0x47cd9dc  
@filename="[…]/eclipse3.2.2/workspace/Test/config/…/tmp/sessions//ruby\_sess.65f3543af8286132",  
@table=nil, @transaction=false, @abort=false, @rdonly=false\>\>]\>

Are there different kinds of sessions? Is there any chance of getting  
access to the session while I do the scaffolding?

Any hint is appreciated!

Thanks & Regards,

Christian
