🎃

chewyでタイプをinteger_rangeにする

2022/11/17に公開
define_type Article do

  field :activity_term, type: :integer_range, value: (lambda do |article|
    range = article.activity_term
    { gte: range&.lower_limit, lte: range&.upper_limit }
  end)
  
  # or
  
  field :activity_term, type: :integer_range, value: ->(article) {{ gte: article.activity_term&.lower_limit, lte: article.activity_term&.upper_limit }}
  
end

Discussion