Session[:aa][:bb]


#1

Why this doesn’t work?

session[:aa][:bb] = “xxx”


#2

On 19 Jan 2009, at 18:05, James B. wrote:

Why this doesn’t work?

session[:aa][:bb] = “xxx”

probably because session[:aa] is nil

Fred


#3

Frederick C. wrote:

On 19 Jan 2009, at 18:05, James B. wrote:

Why this doesn’t work?

session[:aa][:bb] = “xxx”

probably because session[:aa] is nil

Fred

How to “fix” it?

index 25009 out of string


#4

I can’t make this work:

@tmp = “xxx”
session[@tmp][:yyy] = “zzz”


#5

On 19 Jan 2009, at 18:39, James B. wrote:

Fred

How to “fix” it?

index 25009 out of string

that sounds like session[:aa] is a string.
There’s nothing wrong with session[:aa][:bb] = “xxx” assuming the
objects involved are of the right type, which will be down to the rest
of the code in your app

Fred


#6

On Jan 19, 2009, at 3:53 PM, James B. wrote:

I can’t make this work:

@tmp = “xxx”
session[@tmp][:yyy] = “zzz”

and unless you tell us what you expect to happen, no one else can
either. :wink:

Do you expect the Hash implied by session[@tmp] to spring into
existence so you can assign a value to the :yyy key?

In that case, session would have to refer to something like:

Hash.new {|h,k| h[k] = {} }

So:
session = Hash.new {|h,k| h[k] = {} }
@tmp = “xxx”
session[@tmp][:yyy] = “zzz”

puts session.inspect

{“xxx”=>{:yyy=>“zzz”}}

-Rob

Rob B. http://agileconsultingllc.com
removed_email_address@domain.invalid