Okay I'll try and show you what errors I'm getting later.

For now let me try to explain the situation a bit more clearly 
(apologies, I'm still learning, this is my first app and I'm mainly 
doing it to learn rails, quite possibly I'm way off on what I'm doing).

I created a quiz scaffold and used devise to set up users.

When a user logs in, they have a dashboard with a link to 'quiz'. This 
goes to the index action of the quiz controller, which displays all of 
the quizzes. I want to build the actual functionality into the quiz#show 
action, which gets an individual quiz form.

However, the part I'm struggling to understand is this: They 'answers' 
to the quiz have to belong to the user, surely? I can't have an 'answer' 
attribute on the quiz, because then each user would just be updating 
this attribute belonging to quiz each time they submit something (by the 
way, there is only 1 question on each quiz page).

So, I've set up the 'answer' attribute as part of the user. The idea is 
that the user goes to the quiz/:id page, inputs their answer, this is 
then sent using a put update request to edit the users 'answer' 
attribute and manipulate it/check it for correctness.

So my show.html.erb for quiz is something like:

<h1><%= @quiz.title %></h1>

<p>
  <%= @quiz.question %>
</p>

<%= form_for(resource, as: resource_name, url: 
registration_path(resource_name), html: { method: :put }) do |f| %>
  <div><%= f.label :answer %>
  <%= f.text_field :answer %> </div>
    <div><%= f.submit "Submit" %></div>
<% end %>


Does this make sense, or is this there a far easier way of doing it?

I appreciate the help! Thanks.

Joe

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/ca36948e550c7c493d2a29360c9a9168%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to