整数的Ruby数组映射

时间:2012-01-24 07:32:48

标签: ruby activerecord ruby-on-rails-3.1

我有这个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括在引号中?

1 个答案:

答案 0 :(得分:2)

放弃join(',')

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