Search code examples
mysqlruby-on-railsrubyactiverecordjruby

How to override ActiveRecord::Type::Boolean with JRuby


I'm trying override the active record class to return true/false instead of 1/0. The example works like a charm with Ruby, but with JRuby not works.

module ActiveRecord::Type
  class Boolean    
    def type_cast(value, column = nil)
      ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(value) ? false : true
    end
  end
end

Thanks for advance.


Solution

  • Running with Ruby 2.1.x works and not work with JRuby 1.7.x/Ruby 1.9.x. Thanks @ThomasHaratyk