I create form (i want to create the interface for inserting in the table users). Table users has a boolean field, get_newsletter (=if the user want newsletter). In *.rhtml, I have want newsletter <%= radio_button( "user", "get_newsletter", "1", :checked => ''checked'' ) %> dont want newsletter <%= radio_button( "auto", "get_newsletter", "0" ) %> But it''s not working. If the .save method fails (because of other fields), my radio group is not set correctly (other fields are correctly set). Can someone tell me how to work with radio groups and boolean fields in database? Thank you RoR 1.1, mysql 5 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yeah I''m having the same issue. Did you ever get it to work properly? Mark wrote:> I create form (i want to create the interface for inserting in the table > users). > Table users has a boolean field, get_newsletter (=if the user want > newsletter). > > In *.rhtml, I have > > want newsletter <%= radio_button( "user", "get_newsletter", "1", > :checked => ''checked'' ) %> > dont want newsletter <%= radio_button( "auto", "get_newsletter", "0" ) > %> >-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Michael Satterwhite
2006-Nov-13 17:06 UTC
Re: radio buttons with boolean field in database
Mark wrote:> Can someone tell me how to work with radio groups and boolean fields in > database?Not what you''re going to want to hear, but radio buttons don''t work with boolean fields. You can change the type of field to integer and it''ll work great, but not with boolean. So far as I can tell, the only field type that works with boolean is the check box. ---Michael -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hmm, I''m using TinyInt as my MySQL field, and it still doesn''t seem to be working. Michael Satterwhite wrote:> Mark wrote: > >> Can someone tell me how to work with radio groups and boolean fields in >> database? > > Not what you''re going to want to hear, but radio buttons don''t work with > boolean fields. You can change the type of field to integer and it''ll > work great, but not with boolean. > > So far as I can tell, the only field type that works with boolean is the > check box. > > ---Michael-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark wrote:> Can someone tell me how to work with radio groups and boolean fields in > database? > Thank you > > RoR 1.1, mysql 5Should be simple, use true and false, like any boolean value should. I have this work in a production application right now, although it runs on edge, not 1.1 <%= radio_button ''foo'', ''enabled'', false %> <%= radio_button ''foo'', ''enabled'', true %> ActiveRecord then converts the true or false to a 0 or 1 for you, if your database requires it. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---