表单: RailsNotes
用户: dreamable
创建日期: 2020-11-13 02:33:01 UTC
更新日期: 2020-11-13 02:33:38 UTC
引用:(Table ID 3, Record ID 6)

标题 :
Link to current page with plus/merged with a param
笔记 :

Solution

link_to "Page", params.merge(:c => "e")

Error: Rails Unable to convert unpermitted parameters to hash

solution

#If you know which parameters should be allowed in the link, you can call permit with those listed.
params.permit(:param_1, :param_2).merge(:sort => column, :direction => direction, :page => nil)
# OR
params.merge(:sort => column, :direction => direction, :page => nil).permit(:param_1, :param_2, :sort, :direction, :page)
# Risk solution
params.to_unsafe_h.merge
标签: