Add data to table through another

Hi all.

First of all: I have 4 tables:

1) `respondents` with `id` and `email`.

2) `inquires` with id, question_id, `respondent_id`

3) `question_id` with `id` and `text`

4) `answers` with `inquiry_id`, `text`

What i want? I want to do next: in my view I have `question` and `text_field` and `button`. If user something answer on question and press button, this data inserts into `answer` table.

#my_controller (asnwer_controller)

      def create         if request.post?           Answer.create(:inquiry_id=>@inquiry.id.to_s, :text=>params[:text])         end       end

#my_view

    <% form_for :answer, :url => { :controller => 'answer', :action => 'create' } do |f| %>         <%= @questions.id %>. <%= @questions.text %><br />         <%= f.text_area :text, :rols => 10, :cols => 60 %><br />         <%= submit_tag "Send Survey ", :class => "inputBox" %>     <% end %>

I through i something missed in view & controller. Data not pasting now. Please help!

Just looking at this briefly, your controller is expecting @inquiry so it can fill in the inquiry_id field. However in your controller or form you are not setting that up of passing that back in. That would leave you id field blank. Also, when you submit back into the controller you are trying to reference params[:text]. That does not exist since it is inside your form_for :answer. You would need to reference params[:answer][:text] to get at it.

B.