ez-where plugin and type mismatch

I’m getting an error

type mismatch: String given

RAILS_ROOT: ./script/../config/..


Application Trace
|

Framework Trace
|

Full Trace

#{RAILS_ROOT}/app/controllers/ajaxsearch_controller.rb:26:in `=~'
#{RAILS_ROOT}/app/controllers/ajaxsearch_controller.rb:26:in `list'
#{RAILS_ROOT}/app/controllers/ajaxsearch_controller.rb:22:in `list'

cond = EZ::Where::Condition.new do
category_id === [category_id] # these are integers coming in
state_id === [state_id] # same
term_id === [term_id] # same
city =~ ‘%city’ # this would be a string

  title =~ '%title' # string as well
 
  end

Something wrong here ?
Stuart

I don't know this plugin at all, but normally you need to give a

thingie> in a block, so my guess would be:

cond = EZ::Where::Condition.new do |ez|
      ez.category_id === [category_id] # these are integers coming in
      ez.state_id === [state_id] # same
      ez.term_id === [term_id] # same
      ez.city =~ '%city' # this would be a string
      ez.title =~ '%title' # string as well

      end

i could be totally wrong though :smiley:

=~ is looking for a regexp.

instead of providing ‘%city’ try using /city$/

Or something similar.

Cheers

No, '=~' maps to a LIKE SQL action, so the format specified is correct.

He is missing a table name for the block... It should be something
like this..

cond = EZ::Where::Condition.new :some_table_name do
       category_id === [category_id] # these are integers coming in
       state_id === [state_id] # same
       term_id === [term_id] # same
       city =~ '%city' # this would be a string
       title =~ '%title' # string as well
end

_Kevin