Reputation: 703
I am trying to make use of session data in my application and for some reason I don't have something setup right.
The code:
session[:key] = some_value
Generates the following error:
The error occurred while evaluating nil.[]
Other controllers don't have an issue with the session, so I am guessing I missed some basic configuration thing somewhere.
Upvotes: 2
Views: 870
Reputation: 703
Ok, I think I got it figured out now. I had a slightly more complex situation that my example. I actually had the following:
session[:chat_history][chat.from.id] ||= []
So I had an error with double array. I added the following:
session[:chat_history] ||= []
Problem was the first time I did this, I put it in a before_filter method. Apparently the session object is nil in the before_filter method, at least the way I have my application setup.
So I moved the initializer to the methods that actually access the session and life is good again.
Upvotes: 1
Reputation: 6161
It looks like the session variable is nil which makes me think the framework couldn't set it for one of these reasons:
It was stated that some controllers work. Did something have the opportunity to create a session for the user before those controllers ran?
Upvotes: 0