【发布时间】:2016-09-18 10:19:19
【问题描述】:
我使用 Rails,我想要这样的请求:
SELECT * FROM events WHERE id = 5 AND
active = true AND
(current_state = 0 OR current_state = 1)
我写的是这样的:
Event.where(id:5).where(active:true).or(Event.where(current_state:)).or
(Event.where(current_state: 1))
但是当我这样做时,我有这个要求:
SELECT * FROM events WHERE id = 5 AND
active = true AND
current_state = 0 OR current_state = 1
我怎么能有括号?
【问题讨论】:
标签: sql ruby-on-rails models