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
On Thu, 2008-07-17 at 00:32 +0200, Mitko K. wrote:
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
get a better concept first…
Class Question has_many :answers
:id integer primary_key
:answer_id integer, foreign_key # this is the correct answer id
:question :string
Class Answer belongs_to :question
:id integer primary_key
:question_id integer
:answer :string
On Thu, 2008-07-17 at 00:54 +0200, Mitko K. 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.
On Thu, 2008-07-17 at 01:08 +0200, Mitko K. wrote:
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.
On Thu, 2008-07-17 at 00:54 +0200, Mitko K. 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.
re-read my initial reply - it is the best solution I think.
Craig
I read it like four times.
For example I have:
What is the fastest car ? - Answer -> Bugatti
How many minutes are in one hour -> 60
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 ).
On Thu, 2008-07-17 at 01:26 +0200, Mitko K. wrote:
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 ).
no - because if you look, I had ‘question_id’ for each answer, so there
could be as many/few answers associated with each specific question and
only 1 correct answer for each question.