On 23 May 2010 17:52, Smoq wrote:
> In a table "answers" I have columns: question, a1, a2, a3 (these
> columns are answers to the question),
> a_u (user's answer), a_ok (correct answer). Below I have pasted the
> view that I am using for listing questions.
Surely you have a "Question" model, which has the question text, and
the three choices for answers (or even a "Choice" model, with a
"Question :has_may Choices" relationship...), and in the "Answer"
model you just store the question_id and the choice (or choice_id).
> But I have no idea how to list ALL answers at the bottom of the page
> (now I know how to show only one answer). And how (in the most
> effective way) to update the column "a_u" wtith ALL user's answers?
For every question the user completes you have an Answer record
(created when they answer a question, or updated if they're allowed to
edit), so users have many answers, and you can iterate to display all
wherever you wish.
> Could you help me?
>
>
> #-index.htm.erb
> begin--
> Listing answers
>
> <% @answers.each do |answer| %>
>
> <%=h answer.question %>
> />
> <%=h
> answer.a1 %>
> />
> <%=h
> answer.a2 %>
> />
> <%=h
> answer.a3 %>
>
>
>
> <% end %>
>
>
> You selected <%= @data11 %>
> #-index.htm.erb
> end--
>
> In answers_controller I have included:
>
> �...@data11 = params[:answer1]
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.