Search code examples
ruby-on-railsactiverecordwhitelist

whitelisting params that are not in the model attributes


I am trying to pass some extra attributes that are not a part of the model attributes.

 def fulfillment_params
    params.require(:fulfillment).permit(
      :id, :ids, :batch_edit_fulfillment_ids, 
        :remarks,
    )
  end

How am I supposed to do this correctly? batch_edit_fulfillment_ids is a field I am using in one of my forms, but when I try to do an update(fulfillment_params) action, rails assumes that this is one of the fields in my model and throws an error that there is no such field in the model


Solution

  • Try not to pass it to fulfillment_params.
    Use just params[:fulfillment][:batch_edit_fulfillment_ids].