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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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") %> -- http://www.5valleys.com/ http://www.workingwithrails.com/person/8078 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you! This was it!!!! On Mar 5, 11:23 am, Jon Garvin <jgarvin.li...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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") %> > > --http://www.5valleys.com/http://www.workingwithrails.com/person/8078--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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! On Mar 5, 11:23 am, Jon Garvin <jgarvin.li...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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") %> > > --http://www.5valleys.com/http://www.workingwithrails.com/person/8078--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -- http://www.5valleys.com/ http://www.workingwithrails.com/person/8078 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---