I'm writing a role-based security plugin for personal use in my apps. The plugin will attach some helper methods to my models automatically (when I run my new class method 'acts_as_a_foo'). Some of these methods have names defined by data in one of my tables. I've got the metaprogramming part working, but I've run into a timing problem that reveals a flaw in my design.
It's most obvious when in the test environment: I need my model classes declared before I can load fixtures, but the data from those fixtures is needed before I can define my models because that's when I generate all of my method names. I've convinced myself that the timing problem exists in other environments even when fixtures aren't a factor. I think I'm going to go with plan B (store this data in a config file and not in the DB), but I'd like to get advice if anyone else has done something like this succesfully in the past. Has anyone used data from the DB to drive the structure of models? My only other idea was some sort of complex bootstrapping where I declare all of my models with their associations, then I load fixtures, then reopen all of the model classes and continue with their implementation. I'm rejecting this as too complicated, especially for a plugin responsible for security where I want to make testing as simple as possible. --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

