NoMethodError when setting session variable

I know this is dumb, but I can not set a session variable. I get the
followig error:

Processing Base#edit (for 67.174.108.88 at 2006-06-28 17:17:34) [GET]
Session ID: 3c4b2bad18c8bc289b719dc056913be7
Parameters: {“action”=>“edit”, “id”=>“11”, “controller”=>“image”,
“filename”=>"/event/image/11/effect.jpg", “fieldname”=>“image”}

NoMethodError (undefined method []=' for nil:NilClass): /app/controllers/image_controller.rb:13:ininitialize’
/vendor/rails/actionpack/lib/action_controller/routing.rb:483:in
recognize!' /vendor/rails/railties/lib/dispatcher.rb:38:indispatch’
/vendor/rails/railties/lib/fcgi_handler.rb:150:in process_request' /vendor/rails/railties/lib/fcgi_handler.rb:54:inprocess!’
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/./fcgi.rb:600:in each_cgi' /usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/./fcgi.rb:597:ineach_cgi’
/vendor/rails/railties/lib/fcgi_handler.rb:53:in process!' /vendor/rails/railties/lib/fcgi_handler.rb:23:inprocess!’
dispatch.fcgi:25

Here is my Controller Code:

class ImageController < ActionController::Base
def initialize
session[‘curimg’] = Time.now
end

def showtime
       render_text session['curimg']
end

Can anyone see what I am doing wrong??

Hi Ted,

Ted Battreall

I know this is dumb, but I can not set a session variable. I get the
followig error:

I could be mistaken, but it looks to me like the error is telling you
you
have a problem in the controller named Base, action method named edit.
You
didn’t include that code.

Processing Base#edit (for 67.174.108.88 at 2006-06-28 17:17:34) [GET]

hth,
Bill

Wrong Trace:
Here is the right trace and error message.

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.[]=
RAILS_ROOT: ./script/…/config/…

Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/app/controllers/image_controller.rb:13:in initialize' -e:4 #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:483:inrecognize!’
#{RAILS_ROOT}/vendor/rails/railties/lib/dispatcher.rb:38:in dispatch' #{RAILS_ROOT}/vendor/rails/railties/lib/webrick_server.rb:115:inhandle_dispatch’
#{RAILS_ROOT}/vendor/rails/railties/lib/webrick_server.rb:81:in
`service’

Here is my Controller Code:

class ImageController < ActionController::Base
def initialize
session[‘curimg’] = Time.now
end

def showtime
       render_text session['curimg']
end