Gsub error after switching from session to cookies

I have the following code where I’m trying to set some cookies after a
successful login:

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

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

    cookies[:user_name] = { :value => user.name,
                            :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.

Thanks!

Found the answer about 5 seconds after I posted.

Should have been like this:

cookies[:user_id] = user.id.to_s

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs