Try this:
checked=(params[question.id.to_s] == '5'?'checked':false)
The main change is comparing params value to String '5'
and not Integer 5
as the params value is a string itself.
Also you do not need to to_i.to_s.to_sym
, to_s
should suffice but that was not the issue.