我正在尝试让 Rails 生成的 _path 方法给我
/terms_and_conditions?utm_source=source&utm_campaign=pain#some_link
所以我在控制器中尝试了以下内容:
utm_params = {"utm_source" => "sauce", "utm_campaign" => "pain"} # from params
redirect_to terms_and_conditions_path(utm_params.merge(anchor: 'some_link')
我得到了这个,以锚点作为参数:
/terms_and_conditions?anchor=some_link&utm_source=source&utm_campaign=pain
如果我尝试
terms_and_conditions_path(utm_params, anchor: 'some_link')
我得到哈希代替格式,而不是正确的参数(即 no ?
):
/terms_and_conditions.utm_source=source&utm_campaign=pain#some_link
我应该如何传递参数并添加锚点?