Forum: Ruby on Rails Add more 'answers' at once

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B7a61530129ee08580ad575854b42717?d=identicon&s=25 Haall (Guest)
on 2006-02-10 23:03
I'm working on a questionnaire which is a "one to many"-realtion between
a question and some answers.

I can extract the data form the database whitout problems, but I'm
having problems creating a new question - or actually, creating new
answers to a question.

What I would like to have is: A form where you can write a question, and
then 8 (or whatever) text_fields where you can write some answers.
Adding one answer at the time wouldn't be a problem (just like adding a
comment in the screencast on rubyonrails.com), but how do I add more
than one at the time?
What should the names of the text fileds be? How do i add them to the
database?

thanks in advance

Mike
Ff43001ac5fe9805aa6ca2e89d3b7b5d?d=identicon&s=25 Jake Janovetz (janovetz)
on 2006-02-11 00:23
Haall wrote:
> I'm working on a questionnaire which is a "one to many"-realtion between
> a question and some answers.
>
> I can extract the data form the database whitout problems, but I'm
> having problems creating a new question - or actually, creating new
> answers to a question.
>
> What I would like to have is: A form where you can write a question, and
> then 8 (or whatever) text_fields where you can write some answers.
> Adding one answer at the time wouldn't be a problem (just like adding a
> comment in the screencast on rubyonrails.com), but how do I add more
> than one at the time?
> What should the names of the text fileds be? How do i add them to the
> database?
>
> thanks in advance
>
> Mike

Page 356 of the Agile Web Development with Rails book might help you.
Chapter 17.  It explains that if you put:

text_field("answers[]", ...)

That you can build arrays of data.  At least that may be a start for
you.

   Jake
This topic is locked and can not be replied to.