0

I have this Rails 3.1 ActiveRecord query:

Show.where('event_id = ? AND id not in (?)', params[:event_id], @dog.show_entries.map(&:show_id).join(','))

It worked fine when @dog.show_entries.count == 1. When it had more I had problems with the SQL generated, which was:

SELECT "shows".* FROM "shows" WHERE (event_id = 1 AND id not in ('2,1')) ORDER BY date ASC

How do I stop it from enclosing the 2,1 in quotes?

1 Answer 1

2

Drop the join(','):

Show.where('event_id = ? AND id not in (?)', params[:event_id], 
  @dog.show_entries.map(&:show_id))
Sign up to request clarification or add additional context in comments.

Comments

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.