attachinary
attachinary copied to clipboard
Multiple uploads in the server-side?
How can I upload multiple files from the server side (without js)? Currently I am using something like this: view.html.erb:
<%= semantic_form_for @user, url: {action: "create"}, html: {method: "post", :multipart => true} do |f| %>
<div><%= f.input :photos, as: :file, input_html: { multiple: true } %></div>
<%= f.submit "Upload" %>
<% end %>
controller:
params[:user][:photos].each do |file|
current_user.photos.new(file)
current_user.save
end
But it doesn't seem to work. I get "undefined method `stringify_keys' for #Tempfile:/tmp/RackMultipart20140325-7518-143rjhj". Also what is the difference between photos.new and photo_files.new ?
I think there isn't much documentation for the server-side uploads. Many thanks.