Home > Enterprise >  Rails Active Admin unpermitted parameter
Rails Active Admin unpermitted parameter

Time:06-01

I have some problem/issues with active admin on rails, specifically unpermitted params error:

existing active admin parameter

here is the existing active admin parameter

model associated with the main model im working with

As per active admin documentation I should be doin right, as the other attributes for dispatch_information model is being accepted by rails and I was able to read and write with out any issues. Just with this recently added attribute "custom_attorney". Associations already set. and with out declaring an attr_accessor on model file it says this error

No method error

as it seems it cannot read or detect the column that I added for dispatch_information model, while in my console its already there.

When I add it with attr_accessor "while it should not, just to proceed on the form page" then I fill in the attributes need, im getting weird stuff in my console

Console view

as you can see it seems it being added inside efile_order hash instead of dispatch_information_attribute hash, and at the bottom part of the image you can see it says unpermitted parameters, even I added it inside the correct attribute block, we can also notice that the other attributes pf dispatch_information works really fine, just this recently added custom_attorney attribute. I already did everything like migration and other stuff.

Form Input

here is my form where we can see that input is on the same block where dispatch_defendant and dispatch_plaintiff is included and those two attribute works fine as well.

I really dont know what I missed here. TIA

CodePudding user response:

The problem is that custom_attorney should be nested under dispatch_information_attributes you have it in the wrong place so it's unpermitted.

The correct way to do that is to add a block for those attributes and nest them.

- f.simple_fields_for :dispatch_information do |d|
  - d.input :custom_attorney, :input_html => { id: 'new-attorney' }

It may be a good idea to provide an object for dispatch_information if you care for existing data. Assuming your ivar is named @e_filling_order then you should have the following.

- f.simple_fields_for :dispatch_information, @e_filling_order.dispatch_information || @e_filling_order.build_dispatch_information do |d|
  • Related