title: Missing id of message thread in message (accepts_nested_attributes_for)
body: <p>I have two models:</p>
  
  <pre><code>class MessageThread &lt; ActiveRecord::Base
      has_many :messages
      attr_accessible :messages_attributes, :subject
      accepts_nested_attributes_for :messages
  end
  </code></pre>
  
  <p>and</p>
  
  <pre><code>class Message &lt; ActiveRecord::Base
      belongs_to :message_thread
      belongs_to :sender, :polymorphic =&gt; true
      attr_accessible :sender_id, :sender_type, :sender, :content
  end
  </code></pre>
  
  <p>In my <code>new.html.erb</code> view, things look like this:</p>
  
  <pre><code>&lt;%= simple_form_for @message_thread do |f| %&gt;
      &lt;%= f.input :subject, :label =&gt; t('message.subject')%&gt;
      &lt;%= f.simple_fields_for :messages do |m| %&gt;
          &lt;%= m.input :content , :label =&gt; t('message.content') %&gt;
      &lt;% end %&gt;
  
      &lt;%= f.button :submit, t('message.send_message') %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>In my <code>MessageThreadsController</code> things look like this:</p>
  
  <pre><code>def new
     @message_thread = MessageThread.new
     @message_thread.messages.build
  end
  
  def create
     @message_thread = MessageThread.new(params[:message_thread])
     @message_thread.save!
  end
  </code></pre>
  
  <p>The error I'm getting is <code>Message thread can't be blank</code>. How am I suppose to set this <code>message_thread_id</code> if I don't know which will it be before saving the <code>@message_thread</code>? I'm clearly doing something wrong, but I can't figure out what...</p>
  
  <p>Thanks for your help</p>