title: Database + Rails + insert data into 3 tables
body: <p>I have following code. Damn, I stuck with this, I know that is very easy...</p>
  
  <pre><code>  def create
        @question = Question.create(:text =&gt; params[:question][:text], :security_token =&gt; "test"))
  
      if success = @question.save
             respondents = Respondent.find(:all)
             respondents.each do |res|
                  Inquiry.create(:question_id=&gt;res.question.id.to_i, :respondent_id=&gt;res.id.to_i)
             end
      end
  
        render :json =&gt; @question.to_ext_json(:success =&gt; success)
      end
  </code></pre>
  
  <p>As you see, I have 3 tables => questions (id, text, security_token), respondents (id, email) and relation-table called inquiry (id, questiond_id, respondent_id). Before  I start i told that I have 3 record in my email table. I want do following: When I add question, it also watching how many email i have in my tables (now i have 3 as i said) and add info in inqury table.
  for example:
  I NEED FOLLOWING IN MY INQUIRY TABLE (after I have added question):</p>
  
  <pre><code>id  | questiond_id | respondent_id
  1   |     2                  |   1
  2   |     2                  |   2
  3   |     2                  |  3
  </code></pre>
  
  <p>How i can do it? I using each do and check how many email i have, but NOW its doesnt work, dont know why, what i did wrong there in my code?</p>