private method `gsub’ RoR

I am trying to set a cookie in Ruby on Rail as you see below. I have set a session and had it working fine, but now my app is calling for cookies. I know how to set them, I get this crazy error and I don’t have a solution for it. I have searched all over and come up with nothing!

This is the error: private method gsub called for 4:Fixnum
I have never seen the error until I added this line to add a cookie: cookies[:acc] = account.id
Here is the full def:
def login
if session[:user_id]
redirect_to :action => "dash", :controller => "todo"
end
if request.post? and params[:account]
@account = Account.new(params[:account])
account = Account.find_by_email_and_password(@account.email,@account.password)
if account
session[:user_id] = account.id
cookies[:acc] = account.id #<= this is where i added the line
flash[:notice] = "Logged in!"
redirect_to :action => "dash", :controller => "todo"
else
@account.password = nil
flash[:notice] = "Sorry your eamil or password is invalid."
end
end
end

So what am I doing wrong here? I check the browser and it has not set a cookie. Let me know!

Leave a Reply




Created by DesignForWeb company. All rights reserved © 2007-2010. Check also the iPhone / iPad developers blog
Disclaimer
The materials collected in this blog were taken from open access sources. We try our best to preserve the copyrights of original authors and clearly state the authorship as well as link to original source website where it's possible. Please leave your comment if you feel offended by any post or if you dispose of any information about breach of copyright law in this blog. We will do our best to resolve the situation immediately.