Forum: Ruby on Rails ez_where : i'm puzzled

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Steve R. (Guest)
on 2006-04-15 21:50
(Received via mailing list)
I have the following code:

    condition_clause = "%#{@phrase}%" "condition is #{condition_clause}"
    unless @phrase.nil?
      condition = :affiliates do
        affiliate_name =~ "%#{@phrase}%" # <<< here's the problem
      options[:conditions] = condition.to_sql "ajax param is #{@phrase}" "ez condition is #{condition.to_sql}"

The output from the logs is:

ajax param is map
ez condition is

In other words, the the where clause is not being constructed. However,
if I
change the line marked above to:

affiliate_name =~ condition_clause # <<< here's the fix

Everything works. I've ascertained that by the time I'm in operator=~,
that's left is '%%'.

Is there something obvious I've missed about this straightforward


View this message in context:
Sent from the RubyOnRails Users forum at
Ezra Z. (Guest)
on 2006-04-16 00:27
(Received via mailing list)

	Yeah I see what the problem is. I need to add a bit to the
documentation to clarify this. The problem is that inside the block, self is another object internal to the ez_where
plugin. So instance variables with the @ sign are not set because
they are instance variables and you are inside another instance
inside that block. If you make @phrase a local variable by changing
it to phrase without the @ sign it will work properly.

Steve R. (Guest)
on 2006-04-16 00:30
(Received via mailing list)
Thanks so much. That explains the behavior.

View this message in context:
Sent from the RubyOnRails Users forum at
This topic is locked and can not be replied to.