Ruby on rails 在Rails活动记录查询中使用大于或小于
问题有许多问题标签 如何获取所有问题:Ruby on rails 在Rails活动记录查询中使用大于或小于,ruby-on-rails,rails-activerecord,Ruby On Rails,Rails Activerecord,问题有许多问题标签 如何获取所有问题: 有一个名为“javascript”的问题标签 没有人回答 有两个以上的“计票” 以下是表格: Questions is_answered:boolean vote_count:integer QuestionTags name:string question_id:integer 这是我到目前为止提出的问题。它有#1和#2我该怎么办#3? Question.joins(:question_tags).where(question_tag
Questions
is_answered:boolean
vote_count:integer
QuestionTags
name:string
question_id:integer
这是我到目前为止提出的问题。它有#1和#2我该怎么办#3?
Question.joins(:question_tags).where(question_tags: {name: "javascript"}, question: {is_answered: false})
这看起来像一个复制品。您需要的是的字符串或数组语法
更新为在最后一个where子句中包含表名。对于“where vote\u count”子句,如何在“jobs”表中特别设置?我不知道如何在joins()查询中使用该语法,这就是为什么它不是重复的原因。我假设您指的是问题表:
。其中([“{Question.table\u name}.vote\u count>?”,2])
。如果你真的是指作业,那么在获取表格名称时,将Job
而不是Question
。
Question.joins(:question_tags).where(question_tags: {name: "javascript"}, is_answered: false).where(["#{Question.table_name}.vote_count > ?", 2])