我正在尝试在任何操作处理之前预处理params
withto_ar2en_i
函数,我在我的 中有以下内容:ApplicationController
params
application_controller.rb
# translates every params' entity from arabic to english
before_action :param_convert_ar2en_i
private
def param_convert_ar2en_i h = nil, path = []
h ||= params
h.each_pair do |k, v|
if v.respond_to?(:key?)
param_convert_ar2en_i v, [path, k].flatten
else
# something like:
params[[path, k].flatten].to_ar2en_i
end
end
end
问题是我不知道如何应用to_ar2en_i
到嵌套params
路径为[[path, k].flatten]
.
有人可以帮我吗?