Open Nowaker opened 10 years ago
I'll close this because long time is passed. If you need this again, please reopen. Thanks.
Non-collaborators can't reopen.
@Nowaker Oh, sorry. I've reopened!
FWIW - Not yet using ActiveHash, but probably will be by the end of today...
This would be very cool for something related to the use case that led me looking for a static activemodel solution. (Very limited number of records, data is effectively read-only, the column structure changes probably more often than the recordset)
In fact, we're already seeding config data into ActiveRecord for another part of the system via two-tier YAML much like OP presents, that might be easier to manage if in ActiveHash - in that case, there are two different sub-configuration-record types.
So as a newcomer, put this down as a vote for 'cool thing to add somewhere down the line maybe'
This would be extremely helpful.
I'm trying a similar case, where I have two ActiveYaml::Base
models with relations, example:
class PermissionGroupTemplate < ActiveYaml::Base
...
has_many :permission_templates
...
end
class PermissionTemplate < ActiveYaml::Base
...
belongs_to :permission_template_group
...
end
Hence those examples, an structure like this in the yaml files would be interesting:
# permission_group_templates.yml
- id: 1
permission_template_ids: [1]
# permission_templates.yml
- id: 1
permission_group_template_id: 1
idk if the current implementation could support something like that, but it would be useful
EDIT
After a bit tinkering, this actually works :)
I'm surprised you need the permission_template_ids: [1]
since the relationship was already defined in permission_group_templates
For my own future reference would you please share with us:
permission_group_templates.yaml#permission_template_ids
needed?@kbrock as I tested:
_ids
suffix work.include ActiveHash::Associations
in the model, as the documentation states. Nothing more.Also, I didn't tinker with aliases or shortcuts, and so far I don't know how they could work in this case.
Don't you thing this use case should be explicit in the documentation?
This could understand nested structures and create
IsoImage
objects too, along with an appropriate relation.