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!
