title: Trouble creating new nested resource with has_one relationship
body: <p>I am trying to create a nested resource with a has_one relationship.  When the form is submitted all the parameters look right, and it routes correctly to the <code>create</code> action.  However, something is making it error out inside the <code>create</code> action.</p>
  
  <p>Error: <code>undefined method 'new' for nil:NilClass</code></p>
  
  <p>Relevant resources:</p>
  
  <pre><code>#models/employer.rb
  class Employer &lt; ActiveRecord::Base
   has_one :employment_training_opportunity, dependent: :destroy
  end
  
  #models/employment_training_opportunity.rb
  class EmploymentTrainingOpportunity &lt; ActiveRecord::Base
    belongs_to :employer
  end
  </code></pre>
  
  <p>And the controller:</p>
  
  <pre><code>#controllers/employment_training_opportunities_controller.rb
  class EmploymentTrainingOpportunitiesController &lt; ApplicationController
    def create
      @employer = Employer.find(params[:employer_id])
      # error highlights line below
      @employment_training_opportunity = @employer.employment_training_opportunity.new(employment_training_opportunity_params)
      if @employment_training_opportunity.save
        redirect_to @employer, flash: {success: "Employment Opportunities was successfully created"}
      else
        render :new
      end
    end    
  end
  </code></pre>
  
  <p>Some more clues I got:  </p>
  
  <p>When I put in a <code>binding.pry</code> I noticed that it is properly finding the <code>employer</code> resource, so <code>@employer</code> is returning an active record object.  </p>
  
  <p>When I call <code>@employer.employment_training_opportunity</code> it returns <code>nil</code>.  This makes sense because this employer resource does not yet have an associated <code>employment_training_opportunity</code> resource.  </p>
  
  <p>But when I call <code>@employer.employment_training_opportunity.new</code>, that is when it errors out with <code>NoMethodError: undefined method 'new' for nil:NilClass</code>.  I just don't get it because this works just fine with <code>has_many</code> associations for nested resources.</p>