В зависимости от того, как выглядит модель Division
, вы должны иметь возможность генерировать все нужные вам объекты, задавая связи с массивами хэшей. Что-то вроде:
company = {
name: 'Tecnics',
departments: ['HR', 'Sales', 'IT', 'Marketing'],
assignments: ['Government', 'Telecom']
}
departments = [
{name: 'HR', parent_name: 'Tecnics', parent_type: 'Company', assignments: ['Contracts']},
{name: 'Sales', parent_name: 'Tecnics', parent_type: 'Company', assignments: ['Banks'], server: 'Canada'},
{name: 'IT', parent_name: 'Tecnics', parent_type: 'Company' assignments: ['Severs']},
{name: 'Marketing', parent_name: 'Tecnics', parent_type: 'Company', assignments: ['Social Media']}
]
assignments = [
{name: 'Government', parent_name: 'Tecnics', parent_type: 'Company'},
{name: 'Contracts', parent_name: 'HR', parent_type: 'department' server: 'New York'},
{name: 'Banks', parent_name: 'Sales', parent_type: 'department'},
{name: 'Servers', parent_name: 'IT', parent_type: 'department', server: 'Ohio'},
{name: 'Social Media', parent_name: 'Marketing', parent_type: 'department', server: 'Mexico'},
{name: 'Telecom' parent_name: 'Tecnics', parent_type: 'Company'}
]
servers = [
{name: 'Mexico', parent_name: 'Social Media', parent_type: 'assignment'},
{name: 'Canada', parent_name: 'Sales', parent_type: 'department'},
{name: 'Ohio', parent_name: 'Servers', parent_type: 'assignment'},
{name: 'New York', parent_name: 'Contracts', parent_type: 'assignment'}
]