title: Rails: how to set last login datetime
body: <p>I have datetime column named lastlogin in my User table. How can I set (and update) this data when user loggined in?
  I'm triyng something like this in my session controller:</p>
  
  <pre><code>def create
    user = User.find_by_email(params[:email])
    if user &amp;&amp; user.authenticate(params[:password])
      session[:user_id] = user.id
      user.lastlogin = Time.now
      redirect_to root_url
    else
      render "new"
    end
  end
  </code></pre>
  
  <p>user.lastlogin = Time.now not works :(</p>