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

NoMethodError: undefined method `nested_belongs_to' for #<ActiveAdmin::ResourceDSL:0x007ff35fd05160> #3531

Closed
andreydeineko opened this issue Oct 28, 2014 · 7 comments

Comments

@andreydeineko
Copy link

Hey! Here is my SO question: http://stackoverflow.com/questions/26607801/inherited-resources-issue-in-activeadmin-rails-4

I am not 100% sure it is a bug as is, but still it could be an activeadmin issue..

The problem is that routes are being built wrong.
ActiveAdmin.register Discussion
belongs_to :my_active_submission, parent_class: ClientApplication
end

works ok, and gives me
/dev_panel/my_active_submissions/:my_active_submission_id/discussions/:id

but

ActiveAdmin.register Post, namespace: :dev_panel do
belongs_to :discussion
end

gives me
/dev_panel/discussions/:discussion_id/posts/:id
instead of
/dev_panel/my_active_submissions/:my_active_submission_id/discussions/:id/posts/:id

@timoschilling
Copy link
Member

On you Stackoverflow post I read you want to use nested_belongs_to from inherited_resources than you need to go this way:

ActiveAdmin.register Discussion do
  controller do
    nested_belongs_to ...
  end
end

ActiveAdmin has no method nested_belongs_to and supports only belongs_to.
There are many other Issues addressing this problem #2082 and there is a PR for that #3280.
So I close this here as a double.

@andreydeineko
Copy link
Author

Hey @timoschilling, yea, I've seen all these threads before posting.. And I've for sure tried to do it as you've shown, but with no luck - routes did not change and remained the same. It does not really matter how, the only thing is that I've struggled whole day today to get the correct routes, and no good so far..

@timoschilling
Copy link
Member

Yes, that is what I say, ActiveAdmin don't support nested_belongs_to at the moment

@andreydeineko
Copy link
Author

I see. So do you think I have any chance to make these nested models generate proper routes? I tried a lot of things and don't really know, how to go with that

@timoschilling
Copy link
Member

You can try using inherited_resources nested_belongs_to in the controller block and write your routes by hand

@timoschilling
Copy link
Member

@andreydeineko
Copy link
Author

Hey! Thanks a lot for assistance! I've found an acceptable work around, so I'm cool. Thanks once again!

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