简体   繁体   中英

ActionController::UnfilteredParameters - unable to convert unpermitted parameters to hash - Rails 5.1.6

I am getting this error in following code

link_to params.to_h.merge(query_hash), options do
  raw("#{title} " + fa_icon(icon))
end

To fix it i tried following things which didn't work mentioned here

 request.parameters.merge(query_hash)

also

safe_params = params.permit(params.keys.flatten)
link_to safe_params.to_h.merge(query_hash), options do
  raw("#{title} " + fa_icon(icon))
end

But nothing works for me, has anybody gone through such error. Any help is appreciated.

I know this is a late response but I had a similar problem and found a solution so it may be helpful to others.

I had a similar issue with a link where I was passing the ransack parameters in Active Admin. My link to looked similar to yours:

link_to('PRIMARY EMAILS ONLY', export_primary_emails_admin_admin_areas_path(format: "csv", params: params[:q]))

Even though I had set the strong parameters, as per the documentation, I kept getting the same error. The only way I could get this to work was to force the parameter to be permitted using this directly before the link_to.

params[:q].permit!

It is effectively doing the same thing as strong params would in allowing anything in the "q" parameter(s).

ActiveAdmin.register AdminArea do
  permit_params q: []
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM