From: Eric Christopherson Date: 2010-07-30T08:03:05+09:00 Subject: Re: Problem with a lambda not executing immediately On Thu, Jul 29, 2010 at 3:38 PM, Fernando Perez wrote: > Hi, > > I'm using the paperclip plugin for one of my rails app, but my problem > is pure Ruby. I'm not good enough with Ruby and lambdas so I need your > advice. > > Here is the code I am trying to make work: > > class Asset < ActiveRecord::Base > >  has_attached_file :data, :styles => { >    :theora => [:format => :ogv, :processors => lambda {|a| a.video? ? > [:video_converter] : []}}] > } > > end You have an extra } before ]. I'm assuming that wasn't part of your actual script, because then you'd get a syntax error. > > > What fails is the lambda, because in Paperclip behind the scenes this is > what happens: > > @var = style.processors.inject(something) do |file, processor| > ... > end > > style.processors has received the lambda defined earlier. > > > And I get the following error message: > > NoMethodError (undefined method `inject' for #) It looks like style.processors is itself a proc instead of an enumerable. Try to find where it was assigned and make sure you pass the proc inside of an array.