简体   繁体   English

将数组传递给Rails控制器中的回调的if条件时的行为是什么

[英]What is the behaviour when an array is passed to an if condition of a callback in a Rails controller

I saw a callback in a controller that looks something like this: 我在控制器中看到了一个如下所示的回调:

 before_action :do_stuff, if: [:condition_1?, :condition_2?], only: :show

What will be the behaviour of the if condition in this case? 在这种情况下,if条件的行为是什么? The Rails documentation only specifies passing a symbol or a Proc. Rails文档仅指定传递符号或Proc。

如果两个条件都返回truefalsenil以外的其他值,则仅do_stuff方法将被调用以执行show操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM