Ruby on rails 如何在alias\u方法\u链中转发块?
我有一种情况需要使用Ruby on rails 如何在alias\u方法\u链中转发块?,ruby-on-rails,ruby,Ruby On Rails,Ruby,我有一种情况需要使用alias\u method\u chain alias_method_chain :allowed_to?, :update def allowed_to_with_update?(action, context, options={}, &block) if action.eql?(:update) false else allowed_to_without_update?(action, context, options
alias\u method\u chain
alias_method_chain :allowed_to?, :update
def allowed_to_with_update?(action, context, options={}, &block)
if action.eql?(:update)
false
else
allowed_to_without_update?(action, context, options, &block)
end
end
它显示出错误
stack level too deep
在这条线上,
allowed_to_without_update?(action, context, options, &block)
知道如何转发块吗?无法在此处进行检查,但是
别名\u方法\u链
只不过是连接方法的语法糖,因此问号将打破这种模式。也就是说,允许\u在不更新的情况下\u?
不是一种链式方法,这就是为什么会产生“堆栈级别太深”错误的原因。您是否尝试alias allowed\u to,allowed\u to?
然后alias\u method\u chain:allowed\u to,:update…
?