mfournier91
mfournier91

Reputation: 1

Render two model json in rails for angular front end

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?

Upvotes: 0

Views: 63

Answers (1)

Manoj Menon
Manoj Menon

Reputation: 1038

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

Upvotes: 1

Related Questions