"return" from before_save

I wish to exit a before_save block. If I invoke

  return true

in the before_save blockk, I get a

  return can't jump across threads

error return.

Hitting the Pickaxe book, it says that returns from a block will cause this error. (Why? I don't know.)

So ... how does one exit gracefully from a block prior to falling off the end of the block?

Ralph Shnelvar wrote:

I wish to exit a before_save block. If I invoke

  return true

in the before_save blockk, I get a

  return can't jump across threads

error return.

Hitting the Pickaxe book, it says that returns from a block will cause this error. (Why? I don't know.

Nor should you care.

So ... how does one exit gracefully from a block prior to falling off the end of the block?

One doesn't AFAIK. In the general case, you could use a conditional statement or raise an exception. In your case, I'd advise using a method callback instead of a block. Best,

def foo   yield end

foo { return 1; puts 'return'} #=> LocalJumpError: unexpected return

foo { next 1; puts 'not reached'} #=> 1

Fred