You should do it like this:
<%= radio_button_tag "answer_id", answer.id, checked: @test_question.answer_id == answer.id %>
This:
@test_question.answer_id == answer.id
will return either true
or false
, thus checking or unchecking the radio button.
@test_question.answer_id
returns an integer > 0, which is a truthy value, meaning you're checking all the radio buttons. Since only one radio button can be checked, it'll be the last one.