Displaying 4 results from an estimated 4 matches for "answer_id".
2006 Jan 04
4
many to many link table compound primary key explosion
...m
the two fields to prevent duplicate records. When I add the same answer
to the same question more than once, rails attempts to create a
duplicate record and explodes with a MySQL error:
MysqlError: Duplicate entry ''3-3'' for key 1: INSERT INTO
answers_questions (`question_id`, `answer_id`) VALUES (3, 3)
Now, I realise I can fix this by removing the primary key from my
schema, and some would say the primary key is unnecessary, but I think
Rails'' behaviour is wrong. Any thoughts? MySQL in particular supports
"ON DUPLICATE KEY UPDATE" which would help. Should ra...
2006 Jul 01
4
Radio_button in loop problem
Hi all, I can''t figure out why my radio_buttons won''t reflect the values
stored in my database. I read through some of the previous posts -- is
it true that they don''t work with integers?
This is the code I''m using:
<% for question in @survey.questions %>
<%= debug question %>
<%= radio_button ( "question", :question_id,
2006 Apr 02
2
"Quiz" site
Hi,
I am thinking about how to best design a quiz site in RoR. I think it
should be fairly easy, but have run into a wall. In the simplest form,
the view would grab all of the questions for a particular quiz and
display them (e.g. multiple choice, so 4 option buttons per question).
However, I can''t figure out how to "mark" the quiz. The form is
submitted to the
2009 Oct 27
5
Unwanted call to validates_associated
..."position", :dependent => :destroy
has_many :assets, :through => :question_assets, :order =>
"millionaire_question_assets.position"
has_many :answers, :class_name => "MillionaireAnswer", :order =>
"position", :dependent => :destroy
#answer_ids= does not preserve the order so building them instead,
which will set position correctly
def answers=(hash_array)
self.answers.clear
hash_array.each do |hash|
self.answers.build(hash)
end
end
#need to preserve order AND set from path or id
def assets=(hash_array)
sel...