method

register_handler

Importance_1
Ruby on Rails latest stable (v7.1.3.2) - 0 notes - Class: ActiveRecord::PredicateBuilder

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v4.2.9) is shown here.

These similar methods exist in v7.1.3.2:

register_handler(klass, handler) public

Define how a class is converted to Arel nodes when passed to where. The handler can be any object that responds to call, and will be used for any value that +===+ the class given. For example:

MyCustomDateRange = Struct.new(:start, :end)
handler = proc do |column, range|
  Arel::Nodes::Between.new(column,
    Arel::Nodes::And.new([range.start, range.end])
  )
end
ActiveRecord::PredicateBuilder.register_handler(MyCustomDateRange, handler)
Show source
Register or log in to add new notes.