Questions have_many question_tags.
How can I get all questions that:
Here are the tables:
Questions
is_answered:boolean
vote_count:integer
QuestionTags
name:string
question_id:integer
This is the query I have so far. It does #1 and #2. How can I do #3?
Question.joins(:question_tags).where(question_tags: {name: "javascript"}, question: {is_answered: false})
This looks like a duplicate of this question. What you want is the string or array syntax for where.
Question.joins(:question_tags).where(question_tags: {name: "javascript"}, is_answered: false).where(["#{Question.table_name}.vote_count > ?", 2])
Updated to include the table name in the last where clause.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With