Ruby on Rails 2.3.8:在before_filter中未定义params?

时间:2011-07-14 16:55:08

标签: ruby-on-rails

  before_filter :only => :destroy do |controller| 
      controller.is_object_on_same_account_as_current_account_for_id?(controller_name.classify.constantize, params[:id])
  end

生成错误:

NameError: undefined local variable or method `params' 
 app/controller/controller:4

我认为params在整个请求过程中始终可用... = \

2 个答案:

答案 0 :(得分:2)

尝试controller.params[:id],因为为控制器定义了params

答案 1 :(得分:1)

尝试request.params [:id]或controller.request.params [:id]