0

I'm having trouble with postgres syntax.

My code is as follows:

output = Course.select("DISTINCT courses.*").where(:semester => Semester.current_semester(input[:semester])).where(:pending => pending)
output = Section.need_to_filter(input) ? output.joins(:sections) : output.joins("LEFT JOIN sections")
output = output.where(:category => input[:category]) if input[:category]
output = output.where('title ILIKE ?', "%#{input[:search_field]}%") if !input[:search_field].blank?

And here's the error image Error image

It has something to do with the join, because that's where it stops, but since I have sqlite3 in development I'm not sure how to test it efficiently.

Can anyone help?

1
  • 5
    For the future, please please copy-paste the text rather than the screenshot of text. The error is in using LEFT JOIN without ON or USING.
    – Amadan
    Commented May 1, 2015 at 4:04

1 Answer 1

2

You miss ON statement in joins

...
output = Section.need_to_filter(input) ? output.joins(:sections) : output.joins("LEFT JOIN sections ON sections.course_id = courses.id")
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.