There isn't any built-in way to handle this (although actionpack might have a helper for that). I would advise something like this
def to_boolean(s)
s and !!s.match(/^(true|t|yes|y|1)$/i)
end
# or (as Pavling pointed out)
def to_boolean(s)
!!(s =~ /^(true|t|yes|y|1)$/i)
end
What works as well is to use 0 and non-0 instead of false/true literals:
def to_boolean(s)
!s.to_i.zero?
end