Hi
I created nested models: tests-questions-answers
resources :tests do
resources :questions do
resources :answers
end
end
resources :questions
resources :answers
models:
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.text_field :question %>
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?
thanks