I have a int field in my database and would like to check if it''s not 0. Apparently the != in the condition is not working. I''m I doing something wrong? I tried different ways with no luck. Can anyone help? these are the options I tried @allPost = Post.search params[:search], :conditions => ["account_status != 0"] @ allPost = Post.search params[:search], :conditions => ["account_status != ?", 0] @ allPost = Post.search params[:search], :conditions => ["account_status IS NOT ?", 0] @ allPost = Post.search params[:search], :conditions => ["account_status < ?", 1] thanks -- Posted via http://www.ruby-forum.com/.
Looks like I am one step ahead of you Sam, I learned this one yesterday: http://www.ruby-forum.com/topic/187676#new Look a few posts down for the series of "67 != 67" Anyway, the problem is that w/ a HTTP request everything is received as a string. So: account_status.to_i -- Posted via http://www.ruby-forum.com/.
Still not working. I tried @ allPost = Post.search params[:search], :conditions =>["account_status.to_i != ?", 0] @ allPost = Post.search params[:search], :conditions =>"account_status.to_i != 0" Mk 27 wrote:> Looks like I am one step ahead of you Sam, I learned this one yesterday: > > http://www.ruby-forum.com/topic/187676#new > > Look a few posts down for the series of "67 != 67" > > Anyway, the problem is that w/ a HTTP request everything is received as > a string. So: > > account_status.to_i-- Posted via http://www.ruby-forum.com/.
Frederick Cheung
2009-May-24 18:05 UTC
Re: != not working in search query (thinking sphinx)
On May 24, 5:22 pm, Sam Ginko <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Still not working. I tried > > @ allPost = Post.search params[:search], :conditions > =>["account_status.to_i != ?", 0] > > @ allPost = Post.search params[:search], :conditions > =>"account_status.to_i != 0" >Have a look at the documentation for sphinx/thinking sphinx - this isn''t activerecord any more, or SQL. To quote the thinking sphinx docs:> Please keep in mind that Sphinx does not support SQL comparison operators – it has its own query language. The > :conditions option must be a hash, with each key a field and each value a string.In addition, :conditions is for doing full text searches against specific columns you have indexed - for filtering on attribute values you need to use the :with option. Fred> Mk 27 wrote: > > Looks like I am one step ahead of you Sam, I learned this one yesterday: > > >http://www.ruby-forum.com/topic/187676#new > > > Look a few posts down for the series of "67 != 67" > > > Anyway, the problem is that w/ a HTTP request everything is received as > > a string. So: > > > account_status.to_i > > -- > Posted viahttp://www.ruby-forum.com/.