You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ActiveRecord的joins查询时触发RuntimeError: unknown class: Integer错误求助

ActiveRecord的joins查询时触发RuntimeError: unknown class: Integer错误求助

我写了一段ActiveRecord查询代码,想筛选出处于final阶段、event_time早于当前时间,且关联的meetings记录属于指定staff_member的Appn数据:

Appn.where(stage: :final)
        .where('event_time < ?', Time.current)
        .joins('
          meetings ON meetings.application_id = applications.id
          AND meetings.staff_member_id = ?', staff_member.id
        )

但是当我尝试获取查询结果的时候(比如调用.to_a方法),却触发了下面这个错误:

RuntimeError: unknown class: Integer (RuntimeError)
from /Users/sam/.rbenv/versions/3.4.8/lib/ruby/gems/3.4.0/gems/activerecord-7.2.1.1/lib/active_record/relation/query_methods.rb:1833:in 'block in ActiveRecord::QueryMethods#build_join_buckets'

我之前查过类似的问题,但那个场景和我的情况不符,没能解决我的问题,有没有大佬能帮我看看这是哪里出问题了?

备注:内容来源于stack exchange,提问作者Sam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 18:19:28