【发布时间】:2018-01-18 06:34:35
【问题描述】:
型号User 和Article。
在文章模型关系中定义belongs_to :user。在用户模型关系中定义has_many :articles
当我触发下面的查询时,给出成功的结果
Article.select(:name, :id).where(user_id:"fb157fc-a9353453cb95", name:"first")
但是当我触发下面的查询时,它给出了一个错误
Article.select(:name, :id).where("user_id (?)","1bf4c2fc-35c37e15d4b5")
错误 ActiveRecord::StatementInvalid HINT: No function matches the given name and argument types. You might need to add explicit type casts.
但是当我触发下面的查询时,它也会报错
Article.select(:name, :id).where("articles.user_id (?)","1bf4c2fc-35c37e15d4b5")
错误 ActiveRecord::StatementInvalid
【问题讨论】:
标签: ruby-on-rails postgresql ruby-on-rails-5