6

I've whitelisted the params like so:

permit_params(%i{identity os current_ip clients site_ids sites domains})

but I get the following in the log:

{"utf8"=>"✓", "_method"=>"patch", "authenticity_token"=>"aU8vwoMbWcMikSQLSGuVo5XTF+sAopRi0+OhgxXYvSKD9UbLaImB3k+uhf03PpWNiwtrZrEv0wVpT9pIcCkyag==", "server"=>{"identity"=>"", "os"=>"UBUNTU 14.04", "current_ip"=>"123.245.23.24", "site_ids"=>["", "1"]}, "commit"=>"Update Server", "controller"=>"admin/servers", "action"=>"update", "id"=>"1"}
  Server Load (0.2ms)  SELECT  "servers".* FROM "servers" WHERE "servers"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
Unpermitted parameters: :site_ids

My form looks like:

  form do |f|
    f.inputs "Server Details" do
      f.input :identity
      f.input :os, label: 'OS'
      f.input :current_ip, as: :string
      f.input :sites, as: :select, collection: Site.all
    end
    f.actions
  end

Why are params not being allowed despite being whitelisted?

2 Answers 2

13

You need to use array syntax for site_ids:

[:identity, :os, :current_ip, :clients, :sites, :domains, site_ids: []]

So it'd be something like this:

permit_params([:identity, :os, :current_ip, :clients, :sites, :domains, site_ids: []])
0

Rails 6

ActiveAdmin.register Record do
  permit_params :start_date, :classroom_id, :teacher_id, group_ids: []

From model:

class Record < ApplicationRecord
  has_and_belongs_to_many :groups, optional: true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.