-
Notifications
You must be signed in to change notification settings - Fork 186
Open
Description
Hi,
I have a class extending ActiveYaml::Base
as below:
class Item < ActiveYaml::Base
set_root_path Rails.root.join('db', 'static')
field :name
end
# items.yml
- id: 1
name: Animal Welfare
- id: 2
name: Climate Change
- id: 3
name: Asylum Seekers
However when I query the data, it always comes back nested under an attributes
key.
irb(main):020:0> Item.all.as_json
=> [{"attributes"=>{"id"=>1, "name"=>"Animal Welfare"}}, {"attributes"=>{"id"=>2, "name"=>"Climate Change"}}, {"attributes"=>{"id"=>3, "name"=>"Asylum Seekers"}}]
irb(main):023:0> Item.first.as_json
=> {"attributes"=>{"id"=>1, "name"=>"Animal Welfare"}}
Is there a reason why this has to be the case, or can I remove it somehow? It's a bit annoying because I'll eventually want to start using ActiveRecord
, and then we'll have to update the client to stop looking for that key or else start adding it in to the DB records.
Thanks
Metadata
Metadata
Assignees
Labels
No labels