Hello, I am currently writing a rails application which includes multiple models that require attachments. Each model object does have zero or one attachment. The attributes to be saved on each attachment do not differ. I want to use attachment_fu, the successor of the acts_as_attachment plugin. My initial guess was to create one attachment table and use polymorphic associations to associate model objects with their corresponding attachments. To my surprise, this tutorial for acts_as_attachment (http://weblog.techno-weenie.net/articles/acts_as_attachment) states: "Acts as Attachment is designed to be specified on multiple models in your application, rather than having a global Attachment model that other models depend on." Is there a reason for this behaviour? Is my initial idea possible as well? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Peter De Berdt
2007-Feb-21 23:43 UTC
Re: attachment_fu - one or multiple attachment tables?
On 21 Feb 2007, at 18:53, rv dh wrote:> I am currently writing a rails application which includes multiple > models that require attachments. Each model object does have zero > or one > attachment. The attributes to be saved on each attachment do not > differ. > I want to use attachment_fu, the successor of the acts_as_attachment > plugin. > > My initial guess was to create one attachment table and use > polymorphic > associations to associate model objects with their corresponding > attachments. > > To my surprise, this tutorial for acts_as_attachment > (http://weblog.techno-weenie.net/articles/acts_as_attachment) states: > "Acts as Attachment is designed to be specified on multiple models in > your application, rather than having a global Attachment model that > other models depend on." > > Is there a reason for this behaviour? Is my initial idea possible as > well?You can perfectly create a single Attachment class and polymorphically link several other models of your application to it. However, acts_as_attachment and attachment_fu don''t force you into any constraint and it can be quite handy for logical data separation to use several tables for different purposes (e.g. avatars table, image_uploads table, ) Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you very much Peter, this is what I wanted to hear! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---