2012-01-24 72 views
0

我有這樣的Rails 3.1的ActiveRecord查詢:紅寶石陣圖的整數

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

它能正常工作時@dog.show_entries.count == 1。當有更多的我與生成的SQL,這是問題:

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

如何阻止它放入引號內的2,1

回答

2

join(',')

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