Strange behavior with session

Hi,

when I create the following method inside a controller, the result I get is not the one I am expecting. Anybody has an explanation for this strange behavior?

--- code   def strange     if nil       raise "strange"       session = "whatever"     end     render :text => session.inspect   end

Hi Marek,

Hi,

when I create the following method inside a controller, the result I get is not the one I am expecting. Anybody has an explanation for this strange behavior?

--- code   def strange     if nil       raise "strange"       session = "whatever"     end     render :text => session.inspect   end ---

1) This list is for topics around developing the Rails core, not for general Rails questions. Please post your question to the general Rails mailing list (http://groups.google.com/group/rubyonrails-talk). 2) If you want to get a helpful answer to your question, you need to tell a lot more about your problem. What is the result you get? What is the result you expect? What is the "strange behaviour"?

//jarkko

Hi jarkko,

I thought it would be more appropriate on this list... The result I expect is a CGI::Session object, but I do get "nil". The strangeness factor lies in the code of the if statement, that is not executed, but alters my session object. Otherwise the "raise" would happen.

My installed gems are:

actionmailer (1.2.5) actionpack (1.12.5) actionwebservice (1.1.6) activerecord (1.14.4) activesupport (1.3.1) ajax_scaffold_generator (3.1.1) daemons (0.4.4) gem_plugin (0.2.1) money (1.7.1) mongrel (0.3.13.3) rails (1.1.6) rake (0.7.1) sources (0.0.1)

- marek