I have a model say, Company, that have many document. A Document belongs_to Company. Documents are all pdf files so I have to upload them and I think to save them in the filesystem. How you manage document names? Do you create a folder for every company in which save their documents or rename documen name to avoid duplicates or to avoid rewrites? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
On 11 November 2011 10:35, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> How you manage document names? > Do you create a folder for every company in which save their documents > or rename documen name to avoid duplicates or to avoid rewrites?I have a polymorphic AttachingType model, which has a FileAttachment model associated to it. The file attachment stores info about the file size, mime type, original name, etc, and I renamed the file to be the id of the file_attachment object (and the original file extension) and save it to a local folder. If I think I''m going to have *lots* of files in the folder (in the order of tens of thousands), I break the structure down and put all ids beginning with 1 in one sub-folder, 2 goes in another, etc. In my models I create a AttachingTypePhoto (for instance) association and all the rest "just works". I should *really* polish-up the code and stick it in the public domain :-/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
On 11 November 2011 11:56, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 11 November 2011 10:35, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> How you manage document names? >> Do you create a folder for every company in which save their documents >> or rename documen name to avoid duplicates or to avoid rewrites? > > I have a polymorphic AttachingType model, which has a FileAttachment > model associated to it. The file attachment stores info about the file > size, mime type, original name, etc, and I renamed the file to be the > id of the file_attachment object (and the original file extension) and > save it to a local folder.Do you use paperclip? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
On 11 November 2011 11:00, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Do you use paperclip?erm.. no :-) I use a model of my own. Paperclip is great for bunging in a single file attachment (inline, into your model), but wasn''t a very flexible/scalable solution (or at least it wasn''t when I needed to do file attachments a few years ago). By having my own model I can treat files like any other association; and attach one, many, or have different types depend on my needs. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
On 11 November 2011 12:15, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 11 November 2011 11:00, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Do you use paperclip? > > erm.. no :-) > > I use a model of my own. Paperclip is great for bunging in a single > file attachment (inline, into your model), but wasn''t a very > flexible/scalable solution (or at least it wasn''t when I needed to do > file attachments a few years ago). > > By having my own model I can treat files like any other association; > and attach one, many, or have different types depend on my needs.I have Company has_many :documents and Document belongs_to :company Document has various attributes and the pdf file associated. I still don''t understand if paperclip is suitable for my needs in this case. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
On 11 November 2011 11:23, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have Company has_many :documents > and > Document belongs_to :company > > Document has various attributes and the pdf file associated. > I still don''t understand if paperclip is suitable for my needs in this case.That I can''t say. Only you can answer whether it is suitable for your case. Sounds like it probably wouldn''t be the end of the world to use paperclip; but that''s certainly not what you asked at the start of the thread - you were asking about how to manage document names. If you''re planning on using paperclip, doesn''t that handle the file naming for you? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
On 11 November 2011 11:00, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Do you use paperclip?PS The biggest issues I had with paperclip was the unnormalised approach of adding four fields to your model for each file you want to attach, and that it doesn''t (didn''t?) allow multiple file attachments. I''ve just had a goggle, and it appears that I wasn''t the only one, and this blog: cordinc.com/blog/2009/04/multiple-attachments-with-vali.html ...describes a similar solution to what I arrived at. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
On 11 November 2011 12:40, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 11 November 2011 11:00, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Do you use paperclip? > > PS The biggest issues I had with paperclip was the unnormalised > approach of adding four fields to your model for each file you want to > attach, and that it doesn''t (didn''t?) allow multiple file attachments. > > I''ve just had a goggle, and it appears that I wasn''t the only one, and > this blog: > cordinc.com/blog/2009/04/multiple-attachments-with-vali.html > ...describes a similar solution to what I arrived at.Thank you for your answers.> > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
On 11 November 2011 11:40, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> PS The biggest issues I had with paperclip was the unnormalised > approach of adding four fields to your model for each file you want to > attach, and that it doesn''t (didn''t?) allow multiple file attachments.s/unnormalised/demormalised/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
On 11 November 2011 12:42, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 11 November 2011 11:40, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> PS The biggest issues I had with paperclip was the unnormalised >> approach of adding four fields to your model for each file you want to >> attach, and that it doesn''t (didn''t?) allow multiple file attachments.However my doubt is like your how to manage multiple file attachments. In my case Company has many pdf documents. Rather than attach the pdf files directly to Company I''ve created a Document model. Now, Company has_many documents and every document has a pdf file as attachemnt. Do you think this is a valid approach? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
On 11 November 2011 12:28, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Now, Company has_many documents and every document has a pdf file as attachemnt. > Do you think this is a valid approach?Like I said, that''s exactly what I do, so I guess I must think it''s valid :-) You can always set up a "has_many :through" for your Company''s files if you *need* to call "company.files" rather than working though the "company.documents" collection. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.