Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个由数据库表支持的邮件模型。Recipients 是一个序列化数组,其中包含联系人 ID # 和原始电子邮件。我希望能够查询以获取发送给联系人的所有电子邮件。我该如何做 find_by_recipients(包括 contact.id)?
您无法真正查询序列化数据的内部结构。您应该找出一种不同的存储数据的方式,或者获取所有记录并使用 Ruby 以某种方式遍历它们(具体如何执行取决于您,取决于您的风格)。警告:如果有很多记录,后者会很慢。
你有3个选项