Working with a ruby on rails app, rails 7 and ActiveStorage installed. I have a model Order, in my order.rb I include
has_many_attached :files
My orders_controller.rb includes this
def order_params
params.require(:order).permit(
...
:files [],
...
end
And in my Order form I have something like:
<%= f.label :files, t(".anade_los_documentos") %>
<%= f.file_field :files, class: 'form-control', placeholder: 0, multiple: true, onchange: "this.form.requestSubmit()" %>
I get this error
ArgumentError (wrong number of arguments (given 0, expected 1..2)):
app/controllers/orders_controller.rb:808:in `[]'
The line 808 is where I include my :files [] within order_params. But if I'm right, I'm passing files in the update call (see below)
Processing by OrdersController#update as TURBO_STREAM
Parameters:
{"authenticity_token"=>"[FILTERED]", "order"=>{"email"=>"[FILTERED]", "typedocument"=>"Acta de defunción", {
"authenticity_token" => "[FILTERED]", "order" => {
"email" => "[FILTERED]", "typedocument" => "Acta de defunción", "customtz" => "Europe/Brussels",
"files" => ["",
# < ActionDispatch::Http::UploadedFile: 0x0000000109c1a520 @tempfile = # < Tempfile: /var/folders / p2 / tt3rjy5s0m917fhkc4nkfnf80000gp / T / RackMultipart20230830 - 97394 - ginuqt.pdf > , @original_filename = "doc 1.pdf", @content_type = "application/pdf", @headers = "Content-Disposition: form-data; name=\"order[files][]\"; filename=\"doc 1.pdf\"\r\nContent-Type: application/pdf\r\n" > ,
# < ActionDispatch::Http::UploadedFile: 0x0000000109c1a4d0 @tempfile = # < Tempfile: /var/folders / p2 / tt3rjy5s0m917fhkc4nkfnf80000gp / T / RackMultipart20230830 - 97394 - xguoyp.pdf > , @original_filename = "doc 2.pdf", @content_type = "application/pdf", @headers = "Content-Disposition: form-data; name=\"order[files][]\"; filename=\"doc 2.pdf\"\r\nContent-Type: application/pdf\r\n" > ],
"pages" => "1",
"ordertype" => "standardCertifiedTranslation",
"servicenotarisation" => "0",
"serviceapostille" => "0",
"country" => "Selecciona uno",
"urgtypev2" => "no",
"physicalcopyv2" => "false",
"street" => "",
"poblacion" => "",
"zipcode" => "",
"state" => "",
"shippingv2" => "standard",
"prenotes" => ""
},
"locale" => "es", "id" => "716"
}
the problem is in :files []
because it needs to be files: []