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

Can't create multiple level self-joined relation #408

Closed
dsounded opened this issue Feb 6, 2017 · 2 comments
Closed

Can't create multiple level self-joined relation #408

dsounded opened this issue Feb 6, 2017 · 2 comments

Comments

@dsounded
Copy link

dsounded commented Feb 6, 2017

let's say I have associations like this:

belongs_to :parent, class_name: 'SomeClass', inverse_of: :children
has_many :children, class_name: 'SomeClass', foreign_key: :parent_id, inverse_of: :parent

And when I build self-joined forms like this

<%= link_to_add_association f, :children, { partial: 'class/partials/class_fields' } %>

I have infinity loop, I have read about making a limitation for the multiple nesting, but any chances to deal without it ?

@nathanvda
Copy link
Owner

I am assuming your partial contains the same link_to_add_association again.

Every link_to_add_association is pre-rendered at server side. If you do not limit the nesting it will indeed create an endless loop.

If you need to have indefinite nesting, maybe cocoon is not the best tool for you, and you should maybe be using ajax/xhr.

@dsounded
Copy link
Author

dsounded commented Feb 7, 2017

@nathanvda yeah, I see, nested_form can't do the same also, maybe it's not really a good choice in the situation, anyway just wanted to know if it works now, because other topics were way too old.

Thanks, I think we can close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants