I have created some radio boxes as follows: <% f.radio_button :usertype, "false" %>False <% f.radio_button :usertype, "true" %>True where usertpe is a boolean in the db I want to be able to create a default selection and I want to validate the options and ensure that for whatever reason there is always a check in one of the boxes...now I know a proper radio box config will always have one option selected. How do I validate? For example validates_prescence_of: usertype? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Dis Tec wrote:> I have created some radio boxes as follows: > > <% f.radio_button :usertype, "false" %>False > <% f.radio_button :usertype, "true" %>True > > where usertpe is a boolean in the db > > I want to be able to create a default selection and I want to validate > the options and ensure that for whatever reason there is always a check > in one of the boxes...now I know a proper radio box config will always > have one option selected. How do I validate? For example > validates_prescence_of: usertype?Any ideas how to do this? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sun, Aug 1, 2010 at 06:10, Dis Tec <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have created some radio boxes as follows: > > <% f.radio_button :usertype, "false" %>False > <% f.radio_button :usertype, "true" %>TrueWhy not use a checkbox? Then you can be sure it''s either checked or unchecked. Or is this just an example, and there are really more than two values? In that case, you could specify one of them as checked from the start. -Dave -- Specialization is for insects. -RAH | Have Pun, Will Babble! -me Programming Blog: http://codosaur.us | Work: http://davearonson.com Leadership Blog: http://dare2xl.com | Play: http://davearonson.net * * * * * WATCH THIS SPACE * * * * * | Ruby: http://mars.groupsite.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.