title: Required Foreign Key is Being Saved as Null
body: <p>I have a Rails app that has <strong>"Datapoint"</strong> and <strong>"Dataset"</strong> model objects.  Datasets belog to Datapoints.</p>
  
  <p>models/dataset.rb:</p>
  
  <pre><code># Table name: datasets
  #
  #  id         :integer         not null, primary key
  #  name       :string(255)
  #  created_at :datetime
  #  updated_at :datetime
  
  class Dataset &lt; ActiveRecord::Base
    belongs_to :user
    validates :name, :presence =&gt; true
  end
  </code></pre>
  
  <p>models/datapoint.rb:</p>
  
  <pre><code># Table name: datapoints
  #
  #  id         :integer         not null, primary key
  #  dataset    :integer
  #  date       :date
  #  value      :float
  #  created_at :datetime
  #  updated_at :datetime
  
  class Datapoint &lt; ActiveRecord::Base
    belongs_to :dataset
    validates :date, :presence =&gt; true
    validates :dataset, :presence =&gt; true
    validates :value, :presence =&gt; true
  end
  </code></pre>
  
  <p>My controllers/datapoints_controller.rb successfully saves datapoints records:</p>
  
  <pre><code>class DatapointsController &lt; ApplicationController
    def create
      @datapoint = Datapoint.new(params[:datapoint])
      @datapoint.dataset = Dataset.find(current_user.dataset)
      if @datapoint.save
        redirect_to root_path
      else
      end  
    end
  end
  </code></pre>
  
  <p>However, when I look in my database, the <strong>dataset</strong> field for each datapoint entry (which is a required foreign key) is empty.  How is this possible?  </p>