usecase:
if i do multiupload, how could i add comments and additional fields to
'each' file during upload!?



On Fri, Nov 1, 2019 at 1:53 PM Ariel Juodziukynas <arielj...@gmail.com>
wrote:

> I don't think you can use the same attribute name for single and multiple
> attachments at the same time. What you can do is to always have multiple
> files and attach only one file when you get a single file upload. I don't
> understand the use case of your idea.
>
> El vie., 1 nov. 2019 a las 14:41, tom (<tomabr...@gmail.com>) escribió:
>
>> yep - its working.
>> but, can i get the array of filenames in case of multiupload in to the
>> same db field and or vice versa? eg:
>>
>> mount_uploader  :files, FolderAttachmentUploader
>> mount_uploaders  :files, FolderAttachmentUploader
>>
>>
>> On Fri, Nov 1, 2019 at 1:30 PM Ariel Juodziukynas <arielj...@gmail.com>
>> wrote:
>>
>>> I think your problem is here
>>>
>>> <%= form.file_field :files, multiple: true, name:
>>> "folder_attachments[files][]"  %>
>>>
>>> use "folder_attachment[files][]", note "folder_attachment" singular, not
>>> plural since the form is for a single folder_attachment (and that's on your
>>> folder_attachment_params method)
>>>
>>> El vie., 1 nov. 2019 a las 14:19, tom (<tomabr...@gmail.com>) escribió:
>>>
>>>> ok, the plural got me beyond an error message, but i cant see the
>>>> uploaded multiuploaded files. singles files work.
>>>>
>>>> controller code:
>>>>     @folder_attachment = FolderAttachment.new(folder_attachment_params)
>>>>     @folder_attachment.company_id = current_user.cid
>>>>     @folder_attachment.user_id = current_user.id
>>>>
>>>>
>>>>     @folder = Folder.find_by_id(params[:folder_attachment][:folder_id])
>>>>
>>>>     respond_to do |format|
>>>>       if @folder_attachment.save
>>>>         format.html { redirect_to @folder , notice: 'Attachment was
>>>> successfully created.' }
>>>>       #  format.json { render :show, status: :created, location:
>>>> @folder_attachment }
>>>>       else
>>>>         format.html { render :new }
>>>>        # format.json { render json: @folder_attachment.errors, status:
>>>> :unprocessable_entity }
>>>>       end
>>>>     end
>>>>
>>>>
>>>>     def folder_attachment_params
>>>>       params.require(:folder_attachment).permit(:company_id,
>>>> :folder_id, :singlefile, :comment,:tags, {files: []})
>>>>     end
>>>> ==========
>>>> class FolderAttachmentUploader < CarrierWave::Uploader::Base
>>>>   # Include RMagick or MiniMagick support:
>>>>   # include CarrierWave::RMagick
>>>>   # include CarrierWave::MiniMagick
>>>>
>>>>   # Choose what kind of storage to use for this uploader:
>>>>   storage :file
>>>>
>>>>   # storage :fog
>>>>
>>>>   # Override the directory where uploaded files will be stored.
>>>>   # This is a sensible default for uploaders that are meant to be
>>>> mounted:
>>>>   def store_dir
>>>>     "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
>>>>   end
>>>>
>>>>
>>>>
>>>> any ideas?
>>>>
>>>> thx
>>>>
>>>>
>>>>
>>>> On Fri, Nov 1, 2019 at 12:24 PM Ariel Juodziukynas <arielj...@gmail.com>
>>>> wrote:
>>>>
>>>>> Also, use "mount_uploader" singular for the single file and
>>>>> "mount_uploaders" plural for the multiple files
>>>>>
>>>>> El vie., 1 nov. 2019 a las 12:44, tom (<tomabr...@gmail.com>)
>>>>> escribió:
>>>>>
>>>>>> hi,
>>>>>>
>>>>>> i want to have one uploader, but 2 forms:
>>>>>>
>>>>>> <h3>Upload Single Attachment</h3>
>>>>>> <%= simple_form_for(FolderAttachment.new) do |form| %>
>>>>>>   <%= form.error_notification %>
>>>>>>
>>>>>>   <div class="form-inputs">
>>>>>>   <%= form.file_field :singlefile %>
>>>>>>   </div>
>>>>>>
>>>>>>   <%= form.input :folder_id , :as => :hidden , :input_html => {
>>>>>> :value => @folder_current.id}  if @folder_current %>
>>>>>>
>>>>>>   <div class="form-inputs">
>>>>>>   <%= form.input :comment %>
>>>>>>   </div>
>>>>>>
>>>>>>   <div class="form-inputs">
>>>>>>   <%= form.input :tags %>
>>>>>>   </div>
>>>>>>
>>>>>>
>>>>>>   <div class="form-actions">
>>>>>>     <%= form.button :submit %>
>>>>>>   </div>
>>>>>> <% end %>
>>>>>>
>>>>>>
>>>>>> <h3>Upload Multiple Attachments</h3>
>>>>>> <%= simple_form_for(FolderAttachment.new, :html => { :multipart =>
>>>>>> true } ) do |form| %>
>>>>>>   <%= form.error_notification %>
>>>>>>
>>>>>>   <div class="form-inputs">
>>>>>>   <%= form.file_field :files, multiple: true, name:
>>>>>> "folder_attachments[files][]"  %>
>>>>>>   </div>
>>>>>>
>>>>>>   <%= form.input :folder_id , :as => :hidden , :input_html => {
>>>>>> :value => @folder_current.id}  if @folder_current %>
>>>>>>
>>>>>>   <div class="form-actions">
>>>>>>     <%= form.button :submit %>
>>>>>>   </div>
>>>>>> <% end %>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --> no matter what i do, i always get errors on controller leve, eg:
>>>>>> map or others. can an uploader only have 1 mount?
>>>>>>
>>>>>> class FolderAttachment < ApplicationRecord
>>>>>>
>>>>>> belongs_to :folder
>>>>>>
>>>>>>
>>>>>>   mount_uploaders  :singlefile, FolderAttachmentUploader
>>>>>>
>>>>>> mount_uploaders  :files, FolderAttachmentUploader
>>>>>>
>>>>>>
>>>>>>
>>>>>> end
>>>>>>
>>>>>> thx
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Ruby on Rails: Talk" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to rubyonrails-talk+unsubscr...@googlegroups.com.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMenWxfarO9dCY%2B1N98tmMQuXtysykGj58tV%2B83pqNUEOA%40mail.gmail.com
>>>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMenWxfarO9dCY%2B1N98tmMQuXtysykGj58tV%2B83pqNUEOA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Ruby on Rails: Talk" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to rubyonrails-talk+unsubscr...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcAAiPoY4kVqg8GscSjDcomSoOwzeXpe%3D%2B7xmu6gNfwSgQ%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcAAiPoY4kVqg8GscSjDcomSoOwzeXpe%3D%2B7xmu6gNfwSgQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Ruby on Rails: Talk" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to rubyonrails-talk+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMftZEaoDi%3DyQtUERERo9CyRzBQiK3gdzQ3VJcot07WGOA%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMftZEaoDi%3DyQtUERERo9CyRzBQiK3gdzQ3VJcot07WGOA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ruby on Rails: Talk" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to rubyonrails-talk+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcAUdQP4GRMSncqND0bSvKO0ePDO3LVQQNbNzcYqwVFUgg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcAUdQP4GRMSncqND0bSvKO0ePDO3LVQQNbNzcYqwVFUgg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to rubyonrails-talk+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMdRvMphCx%2By596yH8SqVVXjqL1VYnqYUONYNhm7g0S9TQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMdRvMphCx%2By596yH8SqVVXjqL1VYnqYUONYNhm7g0S9TQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcDOwxw%3DCiFnsT8p_wZ_UnxNE%2BzGwA6suhGdbxcu41QKYg%40mail.gmail.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcDOwxw%3DCiFnsT8p_wZ_UnxNE%2BzGwA6suhGdbxcu41QKYg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMd8Uw6ow%2B338KTF9usx4T6gGz%3DYf6P21ymMZgWawx59hw%40mail.gmail.com.

Reply via email to