radio button does not get checked

I am reading information out of the db, but even though the color_ids
match the radio_button does not get checked. Are only strings valid
for comparing? Id is an integer.

<% Color.find(:all).each do |color| %>
<%= radio_button("page", "color_id", "color.id") %> <%= color.name
%><br /><br />
<% end %>

Please help!
Thank you!

Eva wrote:

I am reading information out of the db, but even though the color_ids
match the radio_button does not get checked. Are only strings valid
for comparing? Id is an integer.

<% Color.find(:all).each do |color| %>
<%= radio_button("page", "color_id", "color.id") %> <%= color.name
%><br /><br />
<% end %>

Please help!
Thank you!

You're setting the "value" for the radio button to the String "color.id". Take the quotes off and it should work.

<%= radio_button("page", "color_id", color.id) %>

not

<%= radio_button("page", "color_id", "color.id") %>

Thank you! This was it!!!!

I have this other problem, that "color_id" is not a database column it
is a method that returns an integer on page. But when the button is
clicked I wand to update the columns paint_id of the table page. How
would I do that? I get the error "undefined method".
Please help!
Thank you!

Eva wrote:

I have this other problem, that "color_id" is not a database column it
is a method that returns an integer on page. But when the button is
clicked I wand to update the columns paint_id of the table page. How
would I do that? I get the error "undefined method".
Please help!
Thank you!

in Page, define the following

def color_id=(i)
    #do whatever you need to set the value here.
    #the variable <i> will be the id of the checked box in the submitted form
end