Forum: Ruby on Rails named scope lambda string substitution problem

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.
jdwy (Guest)
on 2008-11-06 11:40
(Received via mailing list)
I have a complex named scope like the following.

named_scope :foo, lambda {|foo, bar|
    foo.each do |d|
      #foo = "this line doesn't work #{s}"
      baz = "something like this works " + s

    bar.each do |b|
  :conditions => {'baz' => 1}

It does some pre-processing to calculate the :conditions hash. The
weird bit is that I get a bizarre syntax error when I try to use
double quoted strings with substitutions. If I use a syntax such as
"A"+str+"B" it's ok, but "A#{str}B" is a syntax error. Any thoughts?

I've tried to replicate it in pure ruby lambda functions but wasn't
able to, leading me to think it may be related to the named scope.

This topic is locked and can not be replied to.