2

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

4

1 回答 1

0
class ApplicationController < ActionController::Base
  protect_from_forgery

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

为我工作

于 2013-01-15T16:55:32.247 回答