Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Handling session variables with mutiple controllers, within a single Rails app.?
2 Posts
Handling session variables with mutiple controllers, within a single Rails app.?

Hi, I am having a problem with using session variables. I have two controllers named 'graduate_students_controller' and 'current_students_controller'. Each of these controllers control different view files. But these controllers and view files belong to the same Rails app. I am using session variables with both these controllers to store session information.

Here's the problem. Let's say I have two view files 'reports/current_students_list', 'reports/graduate_students_list' each controlled separately by the above mentioned controllers.

If I try to open those two web pages from within the same browser and try to work with them simultaneously, I get 'nil object access' error from the firstly loaded page. The 'nil object' refers to a session variable that the first page is supposed to access. However, when I use any of those two web applications individually, they work fine.

The session variables that these two controllers are accessing don't have common names. So there is no reason for a session variable to be overwritten unless the secondly loaded web page is storing a new cookie over the existing one(the one that firstly loaded page has stored) ? This is the only logical reason I can think of. But how can you fix something like this? anyone encountered a similar situation before?

I am using rails version 2.2.2

How do I fix this?

Any suggestion is much appreciated.

I got it fixed. for anyone looking for the solution to a similar problem: http://stackoverflow.com/questions/1115886/rails-how-can-you-access-session-variables-using-multiple-controllers

2 Posts
Login to add your message