无法从Rails请求中删除params

时间:2016-02-09 23:36:55

标签: ruby-on-rails

我很难过。我有一个字符串,其中包含各自参数的所有to_s等价物。我从字符串current_user.privilege.factory中删除了一个,但该属性仍然很好。请帮忙。

  def all_params
    [ticket_attrs, required_attrs, production_attrs, internal_attrs,
     progress_attrs].flatten
  end

  def ticket_params
    if current_user.general_privilege == 'part-admin'
      params.require(:ticket).permit authorized_params
    else
      params.require(:ticket).permit all_params
    end
  end

  def authorized_params
    factory = params[:ticket][:manufacturing_location]

    filtered_params = all_params
    filtered_params.each do |param|
      unless current_user.privilege.send(factory).include?(param.to_s)
        filtered_params.delete param 
      end
    end
  end

1 个答案:

答案 0 :(得分:0)

我让这个工作。

all_params.map! do |key| 
  key if current_user.privilege.send(factory).include?(key.to_s)
end