如何在Active Record POSTGRES中使用BETWEEN搜索字符串数组,

tna*_*ght 1 postgresql activerecord ruby-on-rails ruby-on-rails-5

Subscriptions
    canceled_at: ["2017-04-07T09:52:17-05:00", "2017-04-01T09:52:17-05:00"]
Run Code Online (Sandbox Code Playgroud)

Canceled_at是一个字符串数组.每个元素都是转换为字符串的DateTime.

以上是我的订阅表.我正在尝试查询并查找在给定周内具有cancel_at日期的记录.

date = Date.today

Subscription.where("ANY subscriptions.canceled_at 
    BETWEEN '#{date.beginning_of_week(:sunday)}' 
    AND '#{date.end_of_week(:sunday)}'"
Run Code Online (Sandbox Code Playgroud)

红宝石2.3.1p112

s1m*_*pl3 5

Subscription.where(canceled_at:(date.beginning_of_week(:sunday)..date.end_of_week(:sunday)))
Run Code Online (Sandbox Code Playgroud)

编辑:缺少右括号