1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00

ActiveModel::Attribute::WithCastValue is a private constant in Rails 7.0

and so directly referencing the constant causes
NameError: private constant ActiveModel::Attribute::WithCastValue referenced
This commit is contained in:
Akira Matsuda 2021-12-20 02:29:39 +09:00
parent dbac7d476f
commit 07fafc0561

View file

@ -64,12 +64,12 @@ module Kaminari
@values[:limit] = new_limit
if @arel
case @arel.limit
when Integer
case @arel.limit.class.name
when 'Integer'
@arel.limit = new_limit
when ActiveModel::Attribute::WithCastValue
when 'ActiveModel::Attribute::WithCastValue' # comparing by class name because ActiveModel::Attribute::WithCastValue is a private constant
@arel.limit = build_cast_value 'LIMIT', new_limit
when Arel::Nodes::BindParam
when 'Arel::Nodes::BindParam'
if @arel.limit.respond_to?(:value)
@arel.limit = Arel::Nodes::BindParam.new(@arel.limit.value.with_cast_value(new_limit))
end