I am using composed_of() in a model that maps a complex data structure (simply stored in a blob field in the table) to a custom class. Like this: *class* Master < ActiveRecord::Base composed_of *:marc*, *:class_name* => "Marc", *:mapping* => %w(source) *end* *class* Marc include Comparable ... end This works beautifully so far in both directions (loading up from the db and saving to the db). I am now faced with a particularly difficult problem. In this complex data structure I would like to store values that map back to other tables in the database. For example, one of the elements of the data structure refers to a person. I have a standard People model with all the bells and whistles. When I unravel the complex data structure (in Marc class) I want to lookup people from the people table primarily for data integrity purposes. For this purpose I can store the primary ids of people records in the data structure. Furthermore, when the user comes to edit this data structure (in a ludicrously complicated data entry form) I want them to be able to lookup values from the people table in order to select and insert into this data structure. There are several occurrences of people throughout the data structure so it would be wasteful to perform separate lookups as show.rhtml or edit.rhtml come across them. I have a way of asking the custom class (Marc) to fetch all these "foreign keys" from the data structure before I start building the form and, hence, do one big fetch. My first question is this: is there a way I can use the usual ActiveRecord mechanism to manage this or do I need to manage the satellite tables (People) directly in Marc class. That is if I had Marc class inherit from ActiveRecord::??? like standard models (even though Marc is not a whole table or standard model unto itself) would this be completely illogical? I ask this because it would be nice to take advantage of some of the mechanisms in ActiveRecord without actually being an ActiveRecord if you get my drift. I see the current setup as: Master (db table) --> Marc (custom, non-db) --> People (db table) And lastly - is this the best way of dealing with this type of setup? I would like to hear opinions from people on other possible approaches bearing in mind that the data structure (handled by Marc class) is incredibly complex and cannot be stored in a normalised form in the database. Apologies for such a long post, and kind regards, Chad Thatcher. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---