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

sql - text truncated using perl DBI insert -

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

php - Pass object by reference or value -