Hello Carlos, thank you for your response!
The problem with this radio button is that I have to set the correct
attribute of just one choice to true. I can also use a select button
that makes me select the correct answer, but how can I deal with the
params array?
I try and try and try.... but this message is making me sick:
TypeError (expected Array (got Hash) for param `choices_attributes').
On Feb 23, 1:38 pm, Carlos Antonio da Silva
<
carlosantoniodasi...@gmail.com> wrote:
> Sorry, I didn't have time to look at your issue.
>
> What I can see in stack overflow that is not in your post here, is that
> you're going through each choice to render the fields_for:
>
> <% @question.choices.each do |choice| %>
>
> This is wrong when working with nested attributes imo. If you just build the
> coices before, and do sth like that:
>
> 3.times { @question.choices.build } # controller
>
> <%= question_form.fields_for :choices do |choice_fields| %>
>
> Remember you can use simple_fields_for as well.
> Also, you can use simple form collection_radio to help you:
>
> <%= question_form.association :choices, :as => :radio %>
>
> Please give it a try.
>
> On Wed, Feb 23, 2011 at 9:28 AM, Giannicola Olivadoti
> <
olinic...@gmail.com>wrote:
>
>
>
> > I also posted this question in stackoverflow:
>
> >
http://stackoverflow.com/questions/5090820/rails-radio-button-selecti...