title: Why is the user_id column of the database not being filled?
body: <p>I have a table in the database called pcomment. Each pcomment belongs_to a purchase. A purchase has_many pcomments. additionally, each user has_many pcomments and each pcomment belongs_to user. In the database, the pcomments table has id/user_id/purchase_id/body/created_at/updated_at</p>
  
  <p>Everything is getting filled in correctly except for user_id is still always blank. I want it to be filled in with the user_id of the current signed in user (ie the one who is creating the pcomment.) Both the user_id and pcomment_id are indexed in the table with add_index (during the migration)</p>
  
  <p>Here is the form for the pcomment</p>
  
  <pre><code>  &lt;%= form_for([purchase, purchase.pcomments.build]) do |f| %&gt;
  
      &lt;div class="field"&gt;
        &lt;h4&gt;What deal are you offering?&lt;/h4&gt;
        &lt;%= f.text_field :body %&gt;
  
  
      &lt;/div&gt;
  
  
    &lt;% end %&gt;
  </code></pre>
  
  <p>Here is the pcomments_controller.rb</p>
  
  <pre><code>class PcommentsController &lt; ApplicationController
    before_filter :signed_in_user
    def create
      @purchase = Purchase.find(params[:purchase_id])
      @pcomment = @purchase.pcomments.build(params[:pcomment])
  
      @pcomment.purchase = @purchase
  
      if @pcomment.save
         flash[:success] = "Offer submited!"
         redirect_to :back
      else
        render 'shared/_pcomment_form'
      end
    end
  
    def new
  @pcomment=purchase.pcomments.new
  
    end
  
  
  end
  </code></pre>
  
  <p>If you need more of my code it is at <a href="https://github.com/tradespring1/tradespring/" rel="nofollow">https://github.com/tradespring1/tradespring/</a></p>