Forum: Ruby on Rails gsub error after switching from session to cookies

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
74bd868b70df3590bf94cf7abe563ec4?d=identicon&s=25 Jason (Guest)
on 2007-02-08 20:04
I have the following code where I'm trying to set some cookies after a
successful login:

        cookies[:user_id] = { :value =>, #this is line 27
                              :expires => 18.hours.from_now }

        cookies[:user_role] = { :value => user.role,
                                :expires => 18.hours.from_now }

        cookies[:user_name] = { :value =>,
                                :expires => 18.hours.from_now }

I get the following error message:

private method `gsub' called for 1:Fixnum


#{RAILS_ROOT}/app/controllers/login_controller.rb:27:in `login'

This worked fine when I used session[:user_id], now that I've switched
it to a cookie, it's not working.

74bd868b70df3590bf94cf7abe563ec4?d=identicon&s=25 Jason (Guest)
on 2007-02-08 20:06
Found the answer about 5 seconds after I posted.

Should have been like this:

cookies[:user_id] =
This topic is locked and can not be replied to.