Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deeply nested HABTM doesn't show in 0.10.0.rc3 #1215

Closed
nadeemja opened this issue Sep 29, 2015 · 4 comments
Closed

Deeply nested HABTM doesn't show in 0.10.0.rc3 #1215

nadeemja opened this issue Sep 29, 2015 · 4 comments

Comments

@nadeemja
Copy link

Hi,

I have the following associations between three models:

Event has_many Schedules.
Schedule has_and_belongs_to_many Rooms

In 0.8.3, I get what i want:

-Event
-- Schedules:
---- Rooms:

In 0.10.0.rc3, I only get:

-Event
-- Schedules

I've downgraded to 0.8.3 for now.
Let me know if you need more info.

@NullVoxPopuli
Copy link
Contributor

Hi there!

can you show us your serializer? and controller action where you are rendering the data?

@beauby
Copy link
Contributor

beauby commented Sep 29, 2015

Hi @nadeemja, in 0.10, the default is currently to serialize only the first level of relatinoships (this is being discussed here #1205). You can override this behavior either at the controller level, by specifying the include: '**' option in your render call (like render json: @posts, include: '**'), as soon to be mentioned in the docs (there's a pending PR to add this to the docs), or globally by subclassing ActiveModel::Serializer and overriding serializable_hash.

@NullVoxPopuli
Copy link
Contributor

I'd be careful with '**' though. If you know exactly what associations you want, I think it would be safer to specify those.

@beauby also has a pending PR where you can specify nested relationships in the serializers. see #1193

@beauby
Copy link
Contributor

beauby commented Oct 4, 2015

Closing this for now. Feel free to reopen if needed.

@beauby beauby closed this as completed Oct 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants