Forum: Ruby on Rails Session access

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Christian S. (Guest)
on 2007-04-12 00:24
Hi Folks,

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

So I have something like this:

class MyController < ApplicationController
  active_scaffold :my_model

Now I want to do something more dynamic:

class MyController < ApplicationController
  DynamicModel = {
    set_table_name = "DynamicTableName"

  active_scaffold DynamicModel

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
@hash={:dynamic_table_name=>"MyTable", "flash"=>{}},
@table=nil, @transaction=false, @abort=false, @rdonly=false>>,
@new_session=true, @write_lock=true,
@data={:test_key=>"test_val", "flash"=>{}},
@dbprot=[#<CGI::Session::PStore:0x47d2b30 @hash={:test_key=>"test_val",
"flash"=>{}}, @p=#<PStore:0x47cd9dc
@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,

This topic is locked and can not be replied to.