First, I do know that wice_grid gem is not supporting rails 5 as of now. So, there are issues already flowing around the web.
But now I can't go back as I am in the middle of my web app development.
Issue:
I want a simple datagrid having filter properties in my application. Below is my code:
customers_controller.rb
class CustomersController < ApplicationController
layout "themeLayout"
before_action :permit_params
def index
@grid = initialize_grid(Customer)
end
def permit_params
params.permit!
end
end
index.html.erb
<%= grid(@grid) do |g|
g.column name: 'Id' do |task|
task.id
end
g.column name: 'Name', attribute: 'name' do |task|
task.name
end
g.column name: 'Company Name', attribute: 'company_name' do |task|
task.company_name
end
end %>
log file
to_hash unexpectedly ignores parameter filtering, and will change to enforce it in Rails 5.1.
Enable
raise_on_unfiltered_parameters
to respect parameter filtering, which is the default in new applications.For the existing deprecated behaviour, call #to_unsafe_h instead.
DEPRECATION WARNING: num_pages is deprecated and will be removed in Kaminari 1.0. Please use total_pages instead.
Above code generates the data grid as per the requirement but it is not able to display the filtered results.
As per my primary debugging, I found out that params is having null value which results in this error.
Any pointers will be appreciated...
Follow the warning and add
config.action_controller.raise_on_unfiltered_parameters = true
to config/application.rb
After this .to_hash will convert only permitted params.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With