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

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -