title: Rails - Create parent and child at the same time in has_one belongs_to
body: <p>I'm sur I do it wrong, but I can't see where.
  I've got this two models :</p>
  
  <p><strong>Subscription.rb (child)</strong></p>
  
  <pre><code>class Subscription &lt; ActiveRecord::Base
    attr_accessible :state, :subscriber_id, :subscriber_type, :last_payment
  
    belongs_to :subscriber, polymorphic: true
  
    validates :subscriber_id, presence: true
    validates :subscriber_type, presence: true
  end
  </code></pre>
  
  <p><strong>restorer.rb (Parent)</strong></p>
  
  <pre><code>class Restorer &lt; User
    attr_accessible :firstname, :lastname, :restaurant_attributes, :subscription_attributes
  
    has_one :restaurant, dependent: :destroy, :autosave =&gt; true
    has_one :subscription, as: :subscriber, :autosave =&gt; true
  
    accepts_nested_attributes_for :restaurant
    accepts_nested_attributes_for :subscription
  
  end
  </code></pre>
  
  <p>When I want two create a new restorer, and a new subscription (at the same time)
  It doesn't work :</p>
  
  <pre><code>  def create
      @restorer = Restorer.create params[:restorer]
      @restaurant = @restorer.build_restaurant params[:restorer][:restaurant_attributes]
      @subscription = @restorer.build_subscription params[:restorer][:subscription_attributes]
  
      if @restorer.save
        ...
      else
        ...
      end
    end
  </code></pre>