Very new to angular on rails. Basic app idea is to let anyone view venues. Click on venues. Make comments. At the moment I have a single model: venue. Hard-coded data. Full crud. Renders as JSON. Basically I want nested resources. Comments are not useful except in the context of the venue they belong to. I'm trying to find information about how I should create associations in rails api. Like does the venue have many comments such that active record knows about it? Or do I just pass comments as a hash attribute to the single venue model, and if so, how?
-
1Use ActiveSerializers.. You can override attributes data structures in any format and can easily use nested attributesManoj Menon– Manoj Menon2016-08-20 20:22:56 +00:00Commented Aug 20, 2016 at 20:22
-
Thanks. ActiveSerializers worked well!mfournier91– mfournier912016-08-21 21:02:47 +00:00Commented Aug 21, 2016 at 21:02
-
Can you please upvote for the below answer i had suggested? thanks!Manoj Menon– Manoj Menon2016-08-24 11:35:33 +00:00Commented Aug 24, 2016 at 11:35
Add a comment
|
1 Answer
Use ActiveModelSerializers. You can override attributes data structures in any format and can easily use nested resources.https://github.com/rails-api/active_model_serializers
1 Comment
Manoj Menon
@mfournier91 I understand my answer helped you, Can you please upvote for the above answer i had suggested? thanks!