ActiveModel::Type::Boolean.new.cast(value)

value could be a string, a symbol, an integer or a boolean.

Note that Rails only defines false values and checks against those. All other values are considered to be true.

Values considered to be false are:

strings:

  • "0"
  • "f"
  • "F"
  • "false"
  • "FALSE"
  • "off"
  • "OFF"

symbols:

  • :"0"
  • :f
  • :F
  • :false
  • :FALSE
  • :off
  • :OFF

integers:

  • 0

booleans:

  • false