gpt4 book ai didi

ruby-on-rails - Controller 不继承 before_filter

转载 作者:太空宇宙 更新时间:2023-11-03 16:54:05 25 4
gpt4 key购买 nike

所以我有 ApplicationController.rb:

class ApplicationController < ActionController::Base
protect_from_forgery

def decode_email
params[:email] = URI::decode(params[:email])
end
end

然后是 UsersController.rb:

class UsersController < ApplicationController
before_filter :decode_email, only: [:show]

def show
#blah blah
end
end

现在点击显示操作结果:

undefined local variable or method 'decode_email' for #<UsersController:0x007fb5f216a710>

为什么不继承该方法,以便将其正确用作 before_filter?

最佳答案

class ApplicationController < ActionController::Base
protect_from_forgery

private
def decode_email
params[:email] = URI::decode(params[:email])
end
end

为我工作

关于ruby-on-rails - Controller 不继承 before_filter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14077864/

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