Forum: Ruby on Rails Radio buttons show false when clicked

Fef4211b3574a449d6165e2b4fa49fec?d=identicon&s=25 NN Dodhia (Guest)
on 2013-03-07 13:29
(Received via mailing list)
Hi i have this code :
<%= f.input :xyz, :label => "Select a number:",:collection =>
["twenty.","forty"],
  :as => :radio%>

where xyz is a boolean field, so when i submit my form and check in the
database it shows the selection as false even though i've selected a
radio
button and there's also a validates presence of
Cb8d6a17290fc04c76181246b5faa669?d=identicon&s=25 Gautam Pai (Guest)
on 2013-03-07 14:24
(Received via mailing list)
On Mar 7, 2013 5:58 PM, "NN Dodhia" <aca10nnd@sheffield.ac.uk> wrote:
>
> Hi i have this code :
> <%= f.input :xyz, :label => "Select a number:",:collection =>
["twenty.","forty"],
>   :as => :radio%>
>
> where xyz is a boolean field, so when i submit my form and check in the
database it shows the selection as false even though i've selected a
radio
button and there's also a validates presence of

What do you get in the params?

>
> --
> You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-....
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2013-03-07 14:38
(Received via mailing list)
On 7 March 2013 12:27, NN Dodhia <aca10nnd@sheffield.ac.uk> wrote:
> Hi i have this code :
> <%= f.input :xyz, :label => "Select a number:",:collection =>
> ["twenty.","forty"],
>   :as => :radio%>

Can you point to the docs for the use of :as => :radio in that way, I
can't seem to find it.

>
> where xyz is a boolean field, so when i submit my form and check in the
> database it shows the selection as false even though i've selected a radio
> button and there's also a validates presence of

Note that false is a value, so validates presence of will be quite
happy with false.  It is not the same as nil.

Colin
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.