title: Nested Models Creation
body: <p>I am trying to build a nested model but I have a problem:</p>
  
  <p>In new method in TopicController.rb</p>
  
  <pre><code>def new
    @topic = Topic.new
    @topic.message = Message.find(params[:id])
    @topic.build_comment
  end
  </code></pre>
  
  <p>And now in create I have (1st try):</p>
  
  <pre><code>def create
    @cuser = current_facebook_user.fetch
    @topic = Topic.new(:topic)
  
    respond_to do |format|
      if @topic.save
        format.html { redirect_to(@topic, :notice =&gt; 'Topic was successfully created.') }
      else
        format.html { render :action =&gt; "new" }
      end
    end
  end
  </code></pre>
  
  <p>Error for 1st try:</p>
  
  <pre><code>ActiveRecord::RecordNotFound (Couldn't find Message with ID=1 for Topic with ID=):
  </code></pre>
  
  <p>I also tried (2nd try):</p>
  
  <pre><code>def create
    @cuser = current_facebook_user.fetch
    @topic = Topic.new
    @topic.message = params['topic']['message_id'] #enters nil instead of the message_id
    @topic.comment = params['topic']['comment_id'] #enters nil instead of the comment_id
    @topic.user = User.find(1) #enters correct user_id
  
    respond_to do |format|
      if @topic.save
        format.html { redirect_to(@topic, :notice =&gt; 'Topic was successfully created.') }
      else
        format.html { render :action =&gt; "new" }
      end
    end
  end
  </code></pre>
  
  <p>Error for second try:</p>
  
  <pre><code>No Error but Topic.message_id = nill and Topic.comment_id = nill. Those values are not assigned.
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>Thanks</p>