Select box for multiple models

Hi, guys.

I'm new to Rails and right now I'm trying to write simple test system.
The thing is that I don't know how get data from multiple tables and
put the into one select box. Here is my db scheme and what I want to do.
-> http://mitkokostov.info/images/screenshot.jpg

Thanks in advance,
Mitko Kostov

Hi, guys.

I'm new to Rails and right now I'm trying to write simple test system.
The thing is that I don't know how get data from multiple tables and
put the into one select box. Here is my db scheme and what I want to do.
-> http://mitkokostov.info/images/screenshot.jpg

@answers = Answer.find(:all, :conditions => ["question_id = ?",
@question])

<%= options = [['Select Answer', '']] + @answers.sort { |a,b| a.answer
<=> b.answer }.collect {
        >ans> [ans.answer, ans.id] }
        select 'quiz', 'answer_id', options %>

Craig

Thanks very much, but I want to have suggestions, not only questions and
answers.

>
> @answers = Answer.find(:all, :conditions => ["question_id = ?",
> @question])
>
> <%= options = [['Select Answer', '']] + @answers.sort { |a,b| a.answer
> <=> b.answer }.collect {
> >ans> [ans.answer, ans.id] }
> select 'quiz', 'answer_id', options %>
>
> Craig

Thanks very much, but I want to have suggestions, not only questions and
answers.

Craig White wrote:

Craig White wrote:
>>
>> Thanks very much, but I want to have suggestions, not only questions and
>> answers.
> ----
> either I don't understand your question or you didn't understand my
> answer. The answers file would provide multiple choices for each
> question but only 1 correct answer for each question.
>
> Craig

for example I have one question, answer to that question and multiple
suggestions, but incorrect. The questions in my DB will be very
different, so it will be inappropriate to use other answers as
suggestions to a question.

> re-read my initial reply - it is the best solution I think.
>
> Craig
I read it like four times.

For example I have:

1. What is the fastest car ? - Answer -> Bugatti
2. How many minutes are in one hour -> 60
3. What is the first grafical browser -> Mosaic

With your approich when I get question number 1. What is the fastest car
? the answers in the select box will be Bugatti, 60 and Mosaic and it
will be obvious that the correct answer is Bugatti. Because of this I
add third table which will contain similar, but incorrect answers for
every question and I named it suggestions. So my purpose it to get
question and render its correct answer and some "suggestions" ( through
question_id ).

Sorry, Craig.
I'm so stupid. I really didn't fully understand your way.

Thanks very much.