What wrong?

I can’t make this work:

http://groups.google.com/group/paperclip-plugin/browse_thread/thread/c8f58f0a4ef45d20/95e66f07c5722d96?lnk=gst&q=rename#95e66f07c5722d96

Where I have to place this code?

Paperclip::Attachment.interpolations[:random_key] = lambda do |
attachment, style|
attachment.instance.random_key
end

I always get: undefined method `random_key’

Rais 2.3.2 and paperclip installed by gem

I have this problem only if I run Rails by mongrel_cluster.

./script/server works fine.

As I remember u can not use lambda do do |abc |
end
U must use : lambda {| abc| }

On Mar 26, 6:16 pm, Fresh M. [email protected]

On Fri, Mar 27, 2009 at 2:59 AM, robdoan [email protected] wrote:

As I remember u can not use lambda do do |abc |
end
U must use : lambda {| abc| }

lambda do |abc|

end

is equivalent to

lambda { |abc| … }

Thus, they are both legal in Ruby 1.8 and 1.9.

-Conrad

On Mar 27, 12:28 pm, Conrad T. [email protected] wrote:

is equivalent to

lambda { |abc| … }

Thus, they are both legal in Ruby 1.8 and 1.9.

{} binds more tightly than do…end so you do sometimes need to use ()
to disambiguate, eg

named_scope :foo, lambda { … }

is ok

but

named_scope :foo, lambda do

end

isn’t because ruby thinks that this block is for named_scope, not
lambda.

named_scope(:foo, lambda do

end)

makes it clear to ruby what to do.

Fred