[Rails] Re: Typecasting and boolean attributes

Kevin Olbrich
Thu, 12 Jan 2006 02:20:35 -0000

Derek Haynes wrote:
> when updating, it does not appear that the params[:group][:public]
> value is being typecast correctly.
>
> As params[:group][:public] = "true", "true" should be
resolved to a
> "1" in the database. However, this is not occurring.

What is typecasting?

Seriously, radio buttons return string literals back in the params, so
true comes back as "true".  If you want it to map to 1 or 0, set the
radio button to return "1" or "0".

in ruby at least....

true.to_s => "true"

(true == 1) => false

_Kevin

--
Posted via http://www.ruby-forum.com/.