I’m trying to delete several files based on a list but I’m having problems getting the params from the chekcbox’s
This is my list.haml:
%form(method="post" action="/selection" enctype="multipart/form-data")
- @files.each do |file|
%br
%input{:type => "checkbox", :name => "checkbox[]", :value => "#{file}" }
=file
%br
%input(type='submit' value="Delete Selected Files")
Now, for now I was just trying to see what I get in params, so I can later deal with how to delete this list of files.
params.inspect
“Gives me” ≃> {“checkbox”=>[“yet_another_file.txt”, “file1”, “file2”]}
But I can’t figure out how do I put this into an Array so I can do something like
var.each do |c|
puts c
end
I tried var = params[:checkbox] but var is empty, does anyone now how can I do this?
Thanks
You should use
var = params["checkbox"], since the params key is not a symbol, but a string.