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 に答える