Hello in hoboland! I'd like your advice on a hobo-friendly way to implement a one->many relationship where one of the "many" items needs to be designated as the "active" item.
Imagine an app that needs to track employee data as it changes over time. E.g., class Employee which :has_many AdRecords. Standard rails, so far so good. Now, I need to know which of the many AdRecords is the "current" or "active" profile. The most obvious solution, choosing the most recent item, doesn't work because my ad_records may come into existence out of sequence. I can think of three other approaches: 1. Add a date_applicable field to each ad_record and use a lookup to the most recent as the "active" ad_record 2. Add attribute to Employee class pointing to the instance of the "active" ad_record(e.g., :belongs_to :employee, :foreign_key => "current_ad_record") 3. Add simple boolean attribute to AdRecord class indicating which item is current. On the hobo side, my goal is an Employee view that (a) pulls basic info like email_address from the active ad_record object, and (b) shows a table of all ad_records for the employee, indicating the "active" ad_record in bold or with an asterisk, along with a button to change the ad_record deemed "active." What's the best way for me to structure this relationship, to achieve the desired GUI most simply via hobo? >From a class design standpoint, my instinct is #2 is best; #1 seems rather inflexible (and likely slower), and #3 too liable to corruption (multiple boolean flags where only one can be true seems inferior to a single unique pointer). thanks! monty --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/hobousers?hl=en -~----------~----~----~----~------~----~------~--~---
