Notes:
This magicmodels scans the database on startup, and:
* initialises all model classes that are not all intialised
* creates all relationships: belongs_to, has_many, has_one, has_and_belongs_to_many, and has_many :through
o note that for has_one to be detected, the column must be UNIQUE
o uses foreign keys if possible, and falls back onto using /_id$/ on column names
o creates logical relationship names if non-standard, e.g.
GroupTag.send 'belongs_to', referenced_group, :class_name => Group, :foreign_key => referenced_group_id
Group.send 'has_one', group_tag_as_referenced_group, :class_name => GroupTag, :foreign_key => referenced_group_id)
for has_many this woudl be:
GroupTag.send 'belongs_to', referenced_group, :class_name => Group, :foreign_key => referenced_group_id
Group.send 'has_many', group_tags_as_referenced_group, :class_name => GroupTag, :foreign_key => referenced_group_id)
* adds in validation for all the tables as best it can
* uses the rails logger if available, otherwise prints to STDERR
Changes:
|