Create new object in nested model

I created nested models: tests-questions-answers

resources :tests do
resources :questions do
resources :answers
resources :questions
resources :answers

class Test < ActiveRecord::Base
has_many :questions
accepts_nested_attributes_for :questions, :reject_if => :all_blank

class Question < ActiveRecord::Base
belongs_to :test
has_many :answers
accepts_nested_attributes_for :answers, :reject_if => :all_blank ,
:allow_destroy => true

to create new object for question i wrote in answers’s _form:
<%= render :partial => “questions/question”,
:collection=>@test.questions %>

the view - questions/question:
<%= fields_for_question(question) do |q| %>

<%= q.label :question %>
<%= q.text_field :question %>
<%= q.submit %>

question controler:
def create
@test = Test.find(params[:test_id])
@question = @test.questions.create(params[:question])

But when i click on submit button. it does nothing!

can anyone help me please?

Take a look at these railscasts:

Thank you

But i have another problem:

How to use render(association.to_s.singularize , :f => builder)
when the partial is
in a diffrent folder ?
in the view there are 3 folders: ‘tests’, ‘questions’, ‘answers’.
so in ‘_form’ in folder-‘question’ when there is a call to-
link_to_add_fields(“Add Answer”, test_form, :answers)

i get the error-
missing partial ‘tests/answer_fields’.

it need to be:

  • ‘answers/answer_fields’

what i need to change?