gpt4 book ai didi

ruby-on-rails - 在子 Controller 中的 Action 之前跳过

转载 作者:数据小太阳 更新时间:2023-10-29 08:43:01 25 4
gpt4 key购买 nike

我有一个应用程序 Controller ,我正在其中处理一些身份验证

class ApplicationController < ActionController::Base
before_action :prep_data
def prep_data
# code...
# authenticate
end
end

我有一个继承自这个的 Controller

class OtherController < ApplicationController
def custom_action_method
end
end

我可以为自定义操作方法 custom_action_method 跳过 OtherControllerbefore_action Hook 吗?

最佳答案

我找到了答案,这是语法

class OtherController < ApplicationController
skip_before_action :prep_data, only: [:custom_action_method]

def custom_action_method
end
end

关于ruby-on-rails - 在子 Controller 中的 Action 之前跳过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46691656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com