Re: [Rails] build method

2019-11-01 Thread fugee ohu
On Thursday, October 31, 2019 at 2:15:48 PM UTC-4, Ariel Juodziukynas wrote: > > Use `.size` instead of `.count`. "count" does a database query and since > you only built the element the COUNT db query will return 0. "size" knows > what to do if the association is already initialized so it

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
If you need extra fields for each attachment then you need an extra model to store that data and the carrierwave file for each file you upload. Given the name of the model "FolderAttachment" it looks like that's the model and that it shouldn't have multiple files, it looks like there should be

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread tom
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 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

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
I mean: multiple files can be zero or more, it includes the possibility of having only 1 file attached. El vie., 1 nov. 2019 a las 14:53, Ariel Juodziukynas () escribió: > 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

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
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

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread tom
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 wrote: > I think

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
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)

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread tom
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 =

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
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 () escribió: > hi, > > i want to have one uploader, but 2 forms: > > Upload Single Attachment > <%= simple_form_for(FolderAttachment.new) do |form| %>

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
"always get errors", show the errors then El vie., 1 nov. 2019 a las 12:44, tom () escribió: > hi, > > i want to have one uploader, but 2 forms: > > Upload Single Attachment > <%= simple_form_for(FolderAttachment.new) do |form| %> > <%= form.error_notification %> > > > <%= form.file_field

[Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread tom
hi, i want to have one uploader, but 2 forms: Upload Single Attachment <%= simple_form_for(FolderAttachment.new) do |form| %> <%= form.error_notification %> <%= form.file_field :singlefile %> <%= form.input :folder_id , :as => :hidden , :input_html => { :value => @

Re: [Rails] build method

2019-11-01 Thread fugee ohu
On Friday, November 1, 2019 at 8:53:01 AM UTC-4, Walter Lee Davis wrote: > > > > > On Nov 1, 2019, at 2:12 AM, fugee ohu > > wrote: > > > > > > > > On Friday, November 1, 2019 at 12:12:18 AM UTC-4, Ariel Juodziukynas > wrote: > > If you have: > > item has_many item_item_properties > >

Re: [Rails] build method

2019-11-01 Thread Walter Lee Davis
> On Nov 1, 2019, at 2:12 AM, fugee ohu wrote: > > > > On Friday, November 1, 2019 at 12:12:18 AM UTC-4, Ariel Juodziukynas wrote: > If you have: > item has_many item_item_properties > item_item_property belongs_to item_property > > then you can add a relationship on the item model > >

Re: [Rails] build method

2019-11-01 Thread fugee ohu
On Friday, November 1, 2019 at 12:12:18 AM UTC-4, Ariel Juodziukynas wrote: > > If you have: > item has_many item_item_properties > item_item_property belongs_to item_property > > then you can add a relationship on the item model > > has_many :item_properties, through: :item_item_properties > >