Hi All,
I started out hashes intended to be populated with status info, e.g.
sort_order, for several of my tables. I started ApplicationController
with:
session = {}
tables = [:customers, :invoices, :payments]
tables.each { |tbl| session[tbl] = {} }
session[:tables] = tables
Question 1: I had to include the initialization of session, for
otherwise the assignment in the third line fails. But if Rails has a
built-in ‘session’ hash-like element, why is this assignment
necessary.
I checked that the above code worked by following it up with debugging
code:
logger.debug "Application tables:"
nTables = session[:tables].length
(0..(nTables-1)).each { |i|
symTbl = session[:tables][i]
objElement = session[symTbl]
logger.debug "\t" + symTbl.to_s + " => " + objElement.inspect
}
The log showed that the three empty hashes were indeed created.
I followed that up with a def show_session defined with a copy of the
debugging code. When this method was subsequently invoked by some
other controller, it crashed on the second line because
session[:tables] was nil … because session isn’t persistent, I
believe.
Any ideas on how to correct this situation? I read the two recent
threads about sessions, but they don’t seem to address my problem.
Thanks in Advance,
Richard