gpt4 book ai didi

ruby-on-rails - before_filter : is it possible to specify controller for action?

转载 作者:行者123 更新时间:2023-12-04 10:58:08 24 4
gpt4 key购买 nike

我的 application_controller 中有以下字符串:

  before_filter :login_required, :only => [ :edit, :update, :show, :index ] 

但是如果使用 :show,我需要将 {:controller => 'users', :action => 'show'} 放在异常中。有可能这样做吗?

最佳答案

选项:

  • 使用 skip_before_filter在用户 Controller 中
    skip_before_filter :login_required, :only => :show
  • 如果您的异常情况增加,则将 before_filter 单独应用于每个 Controller 。
  • 关于ruby-on-rails - before_filter : is it possible to specify controller for action?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3664559/

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