开发者

Ruby on Rails 2.3.8: params is undefined in before_filter?

开发者 https://www.devze.com 2023-03-20 04:06 出处:网络
before_filter :only => :destroy do |controller| controller.is_object_on_same_account_as_current_account开发者_StackOverflow社区_for_id?(controller_name.classify.constantize, params[:id])
  before_filter :only => :destroy do |controller| 
      controller.is_object_on_same_account_as_current_account开发者_StackOverflow社区_for_id?(controller_name.classify.constantize, params[:id])
  end

generates error:

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

I thought params was always available throughout the request process... =\


Try controller.params[:id] since params is defined for the controller.


Try request.params[:id] or controller.request.params[:id]

0

精彩评论

暂无评论...
验证码 换一张
取 消