【发布时间】:2019-10-02 21:49:22
【问题描述】:
我有一个Job 资源,example 作为整数变量。 example 是Post 的id,属于User。现在我想查询每条Job 记录,其中example 等于Post,其中该帖子的ID 等于current_user,例如:
@jobs = Job.where(example: Post.where(user_id: current_user.id)).all
这种语法对于测试环境中的 sqlite 似乎是“正确的”,但在 heroku 生产服务器上的 postgres 中会中断。
在尝试上述语法时,Postgres 出现以下错误:
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
如何以 Rails 方式表达?
【问题讨论】:
-
可以分享Job模型吗?
标签: ruby-on-rails postgresql where-clause