簡體   English   中英

控制器不繼承before_filter

[英]Controller not inheriting before_filter

所以我有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

為我工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM