24 Jan 17:28
Re: orphans
On 24 Jan 2008, at 16:17, bingo bob wrote: > > I'm trying to solve the problem of orphaned records, and wondering > what > the best solution is, maybe someone can help me with a little example > code. > > I have the following models. > > Enquiry > Course > > and when someone generates an enquiry they select a course, it all > works > so that I can do the following. > > Enquiry.course.price_per_week * Enquiry.course_duration > > Works great. > > However I have a problem I need to solve. > > The administrator should be able to add, update and delete enquiries > and > also add, update and delete courses. I know this can cause "orphaning" > problems as if an enquiry exists but the course for that enquiry has > been destroyed the record will be invalid and my application will > crash. > > I know about several ways to solve this but I'd like opinions on which > is best and how to achieve it. > > For the time being I removed the ability of the admin to delete > courses > (was thinking of putting in an "archive" boolean to just switch it > off), > but then I'll end up with lots of old rubbish in the DB. I've often gone down the archive route, but that sort of depends on whether you see it as old rubbish or a valuable audit trail Fred --~--~---------~--~----~------------~-------~--~----~ 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@... To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
RSS Feed