ruby-on-rails - 弹性宝石。为什么类的比较不正确?
问题描述
我在我的 rails 项目中使用了elasticsearch-model和elasticsearch-rails gems。搜索后,对一堆记录进行分页并调用记录方法。
records = search_results.page(count).records
当我从记录中获取第一条记录时,例如Product类的实体,并与类比较它返回false,但实体类是Product,为什么?
#returns Product entity
records.first
records.first.is_a?(Product) #=> false
records.first.class == Product #=> false
records.first.class.name #=> "Product"
我可以与 class.name == "Product" 进行比较,但为什么类不能正确比较?
编辑:方法记录返回数据库中的记录集合
解决方案
推荐阅读
- typescript - 打字稿中的剂量[索引:字符串]是什么意思
- python - 如何配置 python mysql.connector 以转换没有字节数组 b'' 的长文本字段
- javascript - 如何在 React Navigation 中更新 initialParams?
- javascript - Safari 中的 JavaScript 问题低于 14
- php - 是否可以在 Laravel 中执行 orderBy() 或 orderBy()?
- razor-pages - 使用 asp-page TagHelper 进行表单元素操作呈现“”而不是正确的 URL
- http - 使用 ArduinoHTTPClient 通过 ESP32 发送 GET 请求时出现问题
- mysql - MySQL JSON 查询错误“字符串中缺少右引号”
- javascript - 如何在 vue3 上延迟加载图像?
- sql - 计算用户在某个日期之后给定时间范围内的记录