在查询SELECT "sheets".* FROM "sheets" WHERE ("sheets"."id" > 5)之后生成的Ransack,但是我想在查询SELECT "sheets".* FROM "sheets" WHERE (((score1 + score2)/2) > 5)中实现公式,基本上我想比较公式而不是属性
发布于 2022-01-09 09:01:57
是的,这可以使用ActiveRecord来完成。我更喜欢从params中获得用户选择的值。
params:
{ filters: [{column: "id", operator: ">", value: 5}] }这样,您就可以在后端构建条件。
condition = ActiveRecord::Base.sanitize_sql('id > 5')然后,您可以将其传递给查询。
Sheet.where(condition)https://stackoverflow.com/questions/70638974
复制相似问题