Topic: Nested Forms [SOLVED]

I am trying to add nested forms to my application
https://github.com/ryanb/nested_form

i was able to add 3 questions the wrong way by adding to the controller

def new
  @service = Service.new
  3.times do
    question = @service.questions.build
  end
end

but my questions are not saving to the DB.

When i but a debuger and i check the params i get

params
{"utf8"=>"✓", "authenticity_token"=>"yP5R+GDogyBUjwMRzGLL8v9cAzr7AB4/dPDl7TjpPGU=", "service"=>{"name"=>"test", "questions_attributes"=>{"0"=>{"question"=>"1", "required"=>"0"}, "1"=>{"question"=>"2", "required"=>"0"}, "2"=>{"question"=>"3", "required"=>"0"}}}, "action"=>"create", "controller"=>"services"}

what i am interested here is the questions_attributes

Last edited by moiseszaragoza (2012-10-01 16:52:30)

Re: Nested Forms [SOLVED]

That gem is no longer recommended. It's much better to code it yourself.
But what's the question? I mean, what is it that you actually want an answer to?

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Nested Forms [SOLVED]

Check your Service model and make sure it has accepts_nested_attributes_for :questions