From: jdwy Date: 2008-11-08T05:33:06+09:00 Subject: Re: named scope lambda string substitution problem Hey Brian, This is the syntax error I get. The code I posted is enough to trigger it in a simple class. I modified and added line numbers below. [user@silvia proj-git]$ ruby foo.rb foo.rb:8: syntax error, unexpected kDO_BLOCK, expecting '}' bar.each do |b| ^ 1 class Foo 2 named_scope :foo, lambda {|foo, bar| 3 foo.each do |d| 4 foo = "this line doesn't work #{s}" 5 baz = "something like this works " + s 6 end 7 8 bar.each do |b| 9 end 10 { 11 :conditions => {'baz' => 1} 12 13 }} 14 end On Nov 7, 1:09 pm, Brian Candler wrote: > jdwy wrote: > > Sorry for a cross post with rails, but I think this may be more of a > > ruby question (or rails's impl?). 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? > > It's clearly not a syntax error. Post the *exact* exception report you > see, together with the exact code which causes it. If you're going to > show just an excerpt, then at least show the line numbers on the excerpt > so these can be tied up to the exception. > -- > Posted viahttp://www.ruby-forum.com/.