【问题标题】:ruby on rails join conditions (with squeel)ruby on rails 连接条件(带 squeel)
【发布时间】:2012-11-01 12:58:57
【问题描述】:

我正在尝试使用 Squeel 来比较连接表之间的属性以及一些数学运算。

这是一个查询示例:

Parent.joins{[child1, child2.grandchildren]}.
where{grandchildren.birth_datetime > Time.now - child1.age.years}

我从 Squeel 收到错误消息“TypeError: can't convert Squeel::Nodes::KeyPath into an exact number”

有人知道我在这里做错了什么吗?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 activerecord squeel


    【解决方案1】:

    Parent.
      joins{[child1, child2.grandchildren]}.
      where{child2.grandchildren.birth_datetime > (Time.current - child1.age.years)}
    

    做这个伎俩?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-01
      • 2011-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多