ActionController::UnfilteredParameters 在 rails 中使用 smart_listing gem 时出错 5
ActionController::UnfilteredParameters error on using smart_listing gem in rails 5
我不知道是什么导致我的 rails 应用程序出现此问题。我正在尝试在我的冲刺模型上应用 smart_listing gem table 排序功能。
冲刺控制器:
def index
@sprints = smart_listing_create :sprints, Sprint.all, partial: "sprints/listing", default_sort: { number: "asc" }
@sprint = Sprint.new
end
...
def permitted_params
params.require(:sprint).permit(:number, :start_date, :end_date)
end
index.html.slim :
= smart_listing_render(:sprints)
_listing.html.slim :
- unless smart_listing.empty?
table.ui.celled.table
thead
th.header = smart_listing.sortable "Number", :number
th.header = smart_listing.sortable "Start Date", :start_date
th.header = smart_listing.sortable "End Date", :end_date
tbody
- smart_listing.collection.each do |sprint|
tr
td.header
= sprint.number
td.description
= "#{sprint.start_date.strftime("%d-%m-%Y")}"
td.description
= "#{sprint.end_date.strftime("%d-%m-%Y")}"
= smart_listing.paginate
- else
p.warning No records!
我知道这会是一些非常小的错误,但我无法在过去 24 小时内解决这个问题:/ 并且无法在 Whosebug/any 其他博客上找到任何其他类似问题。
谢谢:)
目前似乎有一个关于此的GitHub issue。
The following pull changes the behaviour of to_h for unpermitted
params -
This change causes array collections to fail when sorting with the
error "unable to convert unpermitted parameters to hash".
人们解决此问题的一种方法是执行以下操作:
Doing self.params = params.permit!
in the controller before smart_listing_create
also seems to fix the problem.
我要在这里添加一个免责声明。 params.permit!
将允许所有当前和未来的参数。使用它时应该非常小心。 Read the official documentation 获取更多信息。
我不知道是什么导致我的 rails 应用程序出现此问题。我正在尝试在我的冲刺模型上应用 smart_listing gem table 排序功能。
冲刺控制器:
def index
@sprints = smart_listing_create :sprints, Sprint.all, partial: "sprints/listing", default_sort: { number: "asc" }
@sprint = Sprint.new
end
...
def permitted_params
params.require(:sprint).permit(:number, :start_date, :end_date)
end
index.html.slim :
= smart_listing_render(:sprints)
_listing.html.slim :
- unless smart_listing.empty?
table.ui.celled.table
thead
th.header = smart_listing.sortable "Number", :number
th.header = smart_listing.sortable "Start Date", :start_date
th.header = smart_listing.sortable "End Date", :end_date
tbody
- smart_listing.collection.each do |sprint|
tr
td.header
= sprint.number
td.description
= "#{sprint.start_date.strftime("%d-%m-%Y")}"
td.description
= "#{sprint.end_date.strftime("%d-%m-%Y")}"
= smart_listing.paginate
- else
p.warning No records!
我知道这会是一些非常小的错误,但我无法在过去 24 小时内解决这个问题:/ 并且无法在 Whosebug/any 其他博客上找到任何其他类似问题。
谢谢:)
目前似乎有一个关于此的GitHub issue。
The following pull changes the behaviour of to_h for unpermitted params -
This change causes array collections to fail when sorting with the error "unable to convert unpermitted parameters to hash".
人们解决此问题的一种方法是执行以下操作:
Doing
self.params = params.permit!
in the controller beforesmart_listing_create
also seems to fix the problem.
我要在这里添加一个免责声明。 params.permit!
将允许所有当前和未来的参数。使用它时应该非常小心。 Read the official documentation 获取更多信息。