将参数传递给around_action会引发:LocalJumpError没有给出块(产量)

时间:2019-03-25 10:55:33

标签: ruby-on-rails ruby-on-rails-5

我想在around_action中包装我的动作:

around_action { do_stuff("foo") }

我的around_action如下:

def do_stuff(arg)
  some_block do
    Rails.logger.error "arg: #{arg}"
    yield
  end
end

但这会引发LocalJumpError no block given (yield)。我在做什么错了?

1 个答案:

答案 0 :(得分:0)

我最终用以下方法解决了它:

around_action -> (controller, block) { do_stuff("foo", block) }

def do_stuff(arg, block)
  some_block do
    Rails.logger.error "arg: #{arg}"
    block.call
  end
end