Ruby on Rails Wednesday, December 28, 2011

Hi, I’ve just run into a very annoying session problem and judging by my failure to find anything on Google it seems that nobody else has experienced this!

 

I’m trying to set a session variable in application_controller.rb, using simply:

 

@color = “grey”

session[:colors] = @color

 

When trying to look at my site I get:

 

undefined method `session' for ApplicationController:Class

 

 

I’ve used this before and from all the docs this is how I’m supposed to do it! The site was working fine until I tried using session. ApplicationController inherits from ActionController and according to the API documentation, the session stuff is in the actionpack gem which is installed on my system and shows up when I run “bundle install” and “bundle show actionpack”. I’ve also tried “gem update”.

 

I’m using Rails 3.1.0, Gem 1.8.13, Ruby 1.9.2, running on Ubuntu 11.10

 

$bundle show actionpack

> /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0

 

I’ve tried this on two separate sites on the same box, one with Apache2 and one with WEBbrick, even running it as root. The second site is a test site with no changes whatsoever made to startup or initialization files. I’ve checked access rights, chmodding everything to 775, restarting the whole system etc etc and I can’t work out why the blessed thing won’t work!

 

Does anybody have a clue what might be going on?

 

Regards

 

Binni

 

ITAnet

Kirkestien 20
9230  Svenstrup

 

Telefon: 3020 0868

 

Email: binni@itanet.nu

WWW: http://www.itanet.nu

 

 

 

No comments:

Post a Comment