Hi, I have a login controller used to authenticate a user and if login name and password is correct, the record will be updated with the date. it looks like this: def signin if @request.post? @login = @params[:user][:login] logout if @session[:user_id] if @login_user = User.authenticate(@params[:user]) @session[:user_id] = @login_user.id @session[:user_first_login] = @login_user.first_login? @session[:browser] = browser? @login_user.update_attribute(:last_login_date, Time.now) redirect_back_or_default :controller => "start", :action => "index" return end flash.now[:signin_missmatch] = "The e-mail address and password doesn''t match" end render :layout => "decorator-guest" end and in the model i have the authenticate method: def self.authenticate(params) find_first(["login = ? AND pwd = ? AND status=?", params[:login], sha1(params[:pwd]), Status::ACTIVE]) rescue return nil end Every now and then when I try to login (in production enviroment, I haven''t been able to reproduce it in development), Active record tries to update the attributes of my user with the login name of another user. According to the log, the right user is fetched by the User.authenticate method. All the data passed tot the UPDATE statemen is right, except for the login name "otto-3aPgEI9keuCuyJwMYI9mNQ@public.gmane.org", which is another user who has been recently signed in (from another computer). Parameters: {"user"=>{"pwd"=>"xxx", "login"=>"jonas-3aPgEI9keuCuyJwMYI9mNQ@public.gmane.org"}, "commit"=>"", "action"=>"signin", "controller"=>"public"} User Load (0.000406) SELECT * FROM users WHERE (login ''jonas-3aPgEI9keuCuyJwMYI9mNQ@public.gmane.org'' AND pwd = ''89a306879xxxxxxxxxxx47bf3458163da'' AND status=1) LIMIT 1 SQL (0.000033) BEGIN User Update (0.000000) Mysql::Error: Duplicate entry ''otto-3aPgEI9keuCuyJwMYI9mNQ@public.gmane.org'' for key 2: UPDATE users SET `phone` = '''', `login` = ''otto-3aPgEI9keuCuyJwMYI9mNQ@public.gmane.org'', `address` = ''Genvägen 9'', `last_login_date` ''2006-10-02 17:03:24'', `created_by_id` = 0, `zip` = ''374 37'', `pwd` ''89a3068795640xxxxxxx5381ec47bf3458163da'', `nick_name` = '''', `country` ''Sweden'', `status` = 1, `city` = ''Karlshamn'', `mobile_phone` = ''962263'', `last_name` = ''Höglund'', `updated_by_id` = 0, `pref_photo_auto_upload` 0, `first_name` = ''Jonas'', `pref_send_email_and_mobile` = 0, `pref_enable_grag_drop` = 0, `updated_on` = ''2006-10-02 17:03:24'', `state` = '''', `email` = ''jonas-3aPgEI9keuCuyJwMYI9mNQ@public.gmane.org'', `description` = ''Hey fokes. I\''m Jonas, just so you know!'', `created_on` = ''2006-09-25 05:42:33'' WHERE id = 3 SQL (0.000033) ROLLBACK Before I dig to deep into my code, is there anything I should know about, when it comes to things like sessions, threads or likewise that could have an effect on this? Best, /jonas -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---