From: Paul Roche Date: 2010-11-14T00:42:55+09:00 Subject: Re: an each/block problem Phillip Gawlowski wrote in post #961200: > On Sat, Nov 13, 2010 at 4:29 PM, Paul Roche > wrote: >> >> It's plain to see that 'bor' is undefined outside the block. Is there a >> way around this? > > Define it outside the block. ;) but for an 'each' don't I need a block? > >> In simple terms I want to get the value of a certain attribute for each >> user and run that value in a function >> >> out = User.find(:all) > bor = Borrowed.new # Substitute your actual code, obviously. > >> out.each {|bor| bor.books_borrowed} >> >> borrowed.call(bor) > Sorry, could explaini this a bit more. > > -- > Phillip Gawlowski > > Though the folk I have met, > (Ah, how soon!) they forget > When I've moved on to some other place, > There may be one or two, > When I've played and passed through, > Who'll remember my song or my face. -- Posted via http://www.ruby-forum.com/.