I have a model called List which has many records class List has_many :records end class Record end The table Record has 2 permanent fields: name, email. Besides these 2 fields, for each List a Record can have ''n'' custom fields. for example: for list1 I add address(text), dob(date) as custom fields. then while adding records to list one, each record can have values for address and dob. Is there any activerecord plugin which provides this type of functionality. Else could you share your thoughts on how to model this. Thanks in advance, Pankaj -- 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 http://groups.google.com/group/rubyonrails-talk?hl=en.
Are you talking about a dynamic view here? I.E the table ''records'' has 10 fields, but for this particular list only 3 of them are going to be used? BTW, if your table is called "records" it will cause problems for ActiveRecords finds. I suggest you rename it to something else. On Apr 28, 6:21 am, pankaj <pankajbhage...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a model called List which has many records > > class List > > has_many :records > > end > > class Record > > end > > The table Record has 2 permanent fields: name, email. Besides these 2 > fields, for each List a Record can have ''n'' custom fields. > > for example: for list1 I add address(text), dob(date) as custom > fields. then while adding records to list one, each record can have > values for address and dob. > > Is there any activerecord plugin which provides this type of > functionality. Else could you share your thoughts on how to model > this. > > Thanks in advance, Pankaj > > -- > 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@googlegroups.com. > For more options, visit this group athttp://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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
pankaj wrote:> I have a model called List which has many records > > class List > > has_many :records > > end > > class Record > > end > > The table Record has 2 permanent fields: name, email. Besides these 2 > fields, for each List a Record can have ''n'' custom fields. > > for example: for list1 I add address(text), dob(date) as custom > fields. then while adding records to list one, each record can have > values for address and dob. > > Is there any activerecord plugin which provides this type of > functionality. Else could you share your thoughts on how to model > this.If there''s really no common schema beyond name and e-mail, then you have several options to play with: * Use a serialized hash for the "extra" fields. * Put the "extra" fields in some other table and use associations. * Use a schemaless database such as MongoDB. This is not something that SQL databases do easily.> > Thanks in advance, PankajBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/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 http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser wrote:> * Put the "extra" fields in some other table and use associations.You *could* implement a simple "key - key value" model, and tie that back to the record and list since it seems that you''ll have different custom fields per list. Perhaps the "list" model has an associated list of custom field definitions (name, type, size, etc?) Each "record" for the list finds out what its list''s custom fields are, then maintains values for those in its associated table of ''custom field values'' Or something like that... -- 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-/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 http://groups.google.com/group/rubyonrails-talk?hl=en.