Skip to content

Instantly share code, notes, and snippets.

@benjaminwood
Created February 14, 2014 22:47
Show Gist options
  • Save benjaminwood/9011123 to your computer and use it in GitHub Desktop.
Save benjaminwood/9011123 to your computer and use it in GitHub Desktop.
# Active admin relies on a method "boolean_checked?" that is part of a newer version of formtastic that we cannot upgrade to because of surveyor compatibility. This is an initializer monkey patch.
module ActiveAdmin
module Inputs
class FilterBooleanInput < ::Formtastic::Inputs::BooleanInput
def boolean_checked?(value, checked_value)
case value
when TrueClass, FalseClass
value
when NilClass
false
when Integer
value != 0
when String
value == checked_value
when Array
value.include?(checked_value)
else
value.to_i != 0
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment