Come scrivere correttamente?Rails 4 Sintassi - Condizioni multiple
Request.pending.where(.....) ## Request.pending = request.state_id in (1..3)
in cui queste sono le condizioni:
approver1_id = current_user and state_id = 1
or
approver2_id = current_user and state_id = 2
or
approver3_id = current_user and state_id = 3
Sarebbe davvero bello se potessi mettere queste condizioni nel modello per l'uso in altri controller/vista, anche perché userò queste condizioni abbastanza spesso in tutta l'app.
Forse 'Request.pending.where (approver1_id: current_user, state_id: 1)'. O hai bisogno di tutti e 3 in quel momento? – zishe
Spiacente, ho dimenticato l'OR tra ... –