I want to have a where clause with an equal and does not equal condition:
@user = User.where(:user_id => current_user.id, :author_id != current_user.id).nil? ? (render :something) : (render :somethingelse)
The above does not work:
syntax error, unexpected ‘)’,
expecting tASSOC …d, :user_id !=
current_user.id).nil? ? (render
:index) : (re…
If I change the second condition from != to => it will work, however.
How do I have both conditions in one where clase? Thank you
Here’s how you would use Arel to generate the query “
select * from users where user_id = ? and author_id != ?“:Using Arel isn’t as concise as using Hash conditions for simple conditions, but it’s a lot more powerful!
Here’s a link to the full list of predications (
eq,not_eq,gt,lt, etc.) available with Arel.