searchlogic
searchlogic copied to clipboard
Equality Checks not Working
For some reason, when I try to do an _is(#) or _equals(#) or _eq(#), I always get an error about there being the wrong number of arguments.
Table:
Workflow(id: integer, created_by: integer, held_by: integer, prefix: integer, project_id: integer, form_id: integer, fields: text, subject: string, priority: integer, status: integer, due_date: datetime, created_at: datetime, updated_at: datetime)
Records:
+----+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ | id | cre... | hel... | prefix | pro... | for... | fields | sub... | pri... | status | due... | cre... | upd... | +----+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ | 4 | 1 | 1 | 0 | 3 | 9 | 28d... | | 2 | 0 | | 200... | 200... | | 5 | 1 | 1 | 0 | 2 | 7 | | | 2 | 0 | | 200... | 200... | +----+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+
Trying to execute Workflow.status_is(0) results in:
ArgumentError: wrong number of arguments (2 for 1)
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:93:in `attribut
e_condition'
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:93:in `create_p
rimary_condition'
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:151:in `call'
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:151:in `scope_o
ptions'
from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/named_scope.rb:91:in `call'
from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/named_scope.rb:91:in `named_scope'
from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/named_scope.rb:96:in `call'
from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/named_scope.rb:96:in `status_equals'
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:175:in `send'
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:175:in `create_
alias_condition'
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:83:in `create_c
ondition'
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:66:in `method_m
issing'
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/association_conditions.rb:19:
in `method_missing'
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/association_ordering.rb:27:in
`method_missing'
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/ordering.rb:30:in `method_mis
sing'
from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/or_conditions.rb:24:in `metho
d_missing'
from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:in `method_missing'
from (irb):11
It looks like this may be my fault. The problem is that ActiveRecord::Base.attribute_condition only started accepting two arguments when it started supporting end-exclusive ranges, starting at ActiveRecord 2.3.1. I see you're using 2.2.2, which is causing the error.
Is it worth having a version check in there for backwards compatibility?
Could be. I defer to Ben.
Ok, I updated my RAILS_GEM_VERSION from 2.2.2 to 2.3.4 (not sure why I never changed the default :P) and can confirm that it works properly.
I've fixed this in my own branch: http://github.com/xdotcommer/searchlogic