Hello there,
I got this model and I'm trying to get a form around it.
class User
belongs_to :mode
has_many :questions, :through => :mode
has_many :answers
end
class Question
belongs_to :mode
has_many :options
end
class Answer
belongs_to :user
belongs_to :question
belongs_to :option
end
I got this form going on;
<%= simple_form_for @user do |f| %>
<%= f.error_notification %>
<%= f.simple_fields_for :answers do |af| %>
<% @user.questions.each do |q| %>
<%= af.label :question, q.text %>
<%= af.hidden :question, :value =>
q.id %>
<%= af.input :option, :collection => q.options, :as => :radio
<% end %>
<% end %>
<% end %>
What I want with this is that the label contains the question text and
its id in a hidden input, and its available options for the user to
choose.
But this isn't working for me, I clearly don't know how to use this
properly.
Can any1 help me? Thanks