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# - SharpSVN - How to get the previous revision? -

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

url - Querystring manipulation of email Address in PHP -