0
votes

For some reason when I try to access the session object it seems to be returning nil.

This happens mainly in ApplicationController but has also occurred in other controllers too.

"You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[]" - Error message received when accessing session object.

Does anyone know why this might be happening?

1
You should show some code. How does the method which raises the exception look?Arsen7

1 Answers

2
votes

are you using rails 3 by any chance? Rails 3 defaults to cookie-based sessions - sounds like you are expecting AR based sessions ... to setup ar based sessions

#create the table
rake db:sessions:create

#rake the db
rake db:migrate

#tell you app about it in config/initializers/session_store.rb:
Rails.application.config.session_store :active_record_store