# Named scope lambda string substitution problem

**URL:** <https://www.ruby-forum.com/t/named-scope-lambda-string-substitution-problem/152676>\
**Category:** Rails\
**Created:** [November 6, 2008, 10:40am UTC](https://www.ruby-forum.com/t/named-scope-lambda-string-substitution-problem/152676 "2008-11-06T10:40:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdwy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e495f1/32.png) [@jdwy](https://www.ruby-forum.com/u/jdwy)\
**Post date:** [November 6, 2008, 10:40am UTC](https://www.ruby-forum.com/t/named-scope-lambda-string-substitution-problem/152676/1 "2008-11-06T10:40:41Z")

</div>

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  
end

```
bar.each do |b|
end

```

{  
: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.

-Jeff
