Session access


#1

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