Rails Model find where not equal



  • 2 Answer(s)

    Rails 4.x: 

    GroupUser.where.not(user_id: me)
    

    Rails 3.x:

    GroupUser.where(GroupUser.arel_table[:user_id].not_eq(me))
    

    A Store GroupUser.arel_table in variable  inside the model GroupUser  scope it can use arel_table[:user_id] instead of GroupUser.arel_table[:user_id]

    Answered on January 10, 2019.
    Add Comment

    Rails 4:

    GroupUser.where.not(user_id: me)
    

    Answered on January 10, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.