Rails 3. Where NOT query. How to? -
i developing api in rails 3 , let users search user table find friends not want them find them self in search results. how can alter below query make sure users id not among query results.
user.where("lower (firstname) ? or lower (lastname) ?", "%#{@query}%" , "%#{@query}%")
thankful input!
you can add condition query:
user.where("(lower (firstname) ? or lower (lastname) ?) , (id != ?)", "%#{@query}%" , "%#{@query}%", current_user.id)
Comments
Post a Comment