title: Rails 3: Filling a form/database field automatically based on current user?
body: <p>I have a <strong>posts</strong> model in my rails app that has a form/database field for a <strong>sender</strong> that I want to automatically fill with the <strong>current_user</strong> as generated by Authlogic. Basically I want to keep track of the person who created/sent the "post" and not allow them to change that field. </p>
  
  <p>I tried using the following trick from another StackOverflow question below which works as long as there is a field in the form.</p>
  
  <pre><code>def new
     @post = Post.new :sender =&gt; current_user.username
  
     respond_to do |format|
       format.html # new.html.erb
       format.xml  { render :xml =&gt; @post }
     end
  end
  </code></pre>
  
  <p>What I'm looking for is a way to auto-fill that value in the database, hidden from the user, and not requiring a form entry.</p>
  
  <p>What's the best way to go about this?</p>
  
  <p>Thanks in advance for your help!</p>
  
  <p>~Dan</p>