title: Access current_user in model
body: <p>I have 3 tables </p>
  
  <pre><code>items (columns are:  name , type)
  history(columns are: date, username, item_id)
  user(username, password)
  </code></pre>
  
  <p>When a user say "ABC" logs in and creates a new item, a history record gets created  with the following after_create filter.
  How to assign this username ‘ABC’ to the username field in history table through this filter.</p>
  
  <pre><code>class Item &lt; ActiveRecord::Base
    has_many :histories
    after_create :update_history
    def update_history
      histories.create(:date=&gt;Time.now, username=&gt; ?) 
    end
  end
  </code></pre>
  
  <p>My login method in session_controller</p>
  
  <pre><code>def login
    if request.post?
      user=User.authenticate(params[:username])
      if user
        session[:user_id] =user.id
        redirect_to( :action=&gt;'home')
        flash[:message] = "Successfully logged in "
      else
        flash[:notice] = "Incorrect user/password combination"
        redirect_to(:action=&gt;"login")
      end
    end
  end
  </code></pre>
  
  <p>I am not using any authentication plugin. I would appreciate if someone could tell me how to achieve this without using plugin(like userstamp etc.) if possible.</p>