active_admin-subnav
active_admin-subnav copied to clipboard
[discussion] update to recent activeadmin features
Hello @zorab47 , hope you're doing well and someday this gem will be merged to activeadmin. I just wanted to notify you about next changes that can reflect to this gem.
-
about pages pages are supports belongs_to, so there is no reason to skip pages from
active_admin-subnav
take a look https://github.com/activeadmin/activeadmin/pull/4759 -
about extra setup
# Provide access to the parent resource record: Site. # Without this extra setup the parent record will not be accessible. Any # calls to `#parent` will return the Arbre parent element and not the # ActiveAdmin resource.
can you explain why this needed ? and why it is not possible to use helpers.parent
in arbre
https://github.com/Fivell/activeadmin/blob/05877d45d464d1911ca7d53072c81516c7614281/features/registering_pages.feature#L181
- about controller hack
https://github.com/zorab47/active_admin-subnav/blob/master/lib/active_admin/subnav/extensions/base_controller.rb#L11
Can you please explain why this needed, maybe we'll find more clean workaround for this
Thanks
I'm happy to help get this integrated into ActiveAdmin. Answers are below:
- Pages aren't skipped. They just require a bit more setup due to item 2 (calling
#parent
in Arbre context) - It has to do with the Arbre context and variable resolution. My thought is Arbre is intercepting the call for 'parent' though its use of method_missing and returns the parent HTML node. It should be the same issue discussed in https://github.com/activeadmin/activeadmin/pull/2770. Solving this issue would be very helpful in many places.
- It is possible to use
helpers.parent
, but it seems strange when the docs for inherited_resources's belongs_to suggest using thecontroller#parent
method directly. - I didn't realize that Arbre provided the
helpers
method for this purpose until you mentioned it.
- It is possible to use
- The controller hack is to ensure the ID of the parent resource is available when generating URLs for the sub menu items (if I remember correctly).
Have you experienced the issue related to calling #parent
in an Arbre context? Perhaps my resources are configured in a strange way??
@zorab47 , yes I had, but after I figured out that parent can be called on helpers.
So helpers.parent
works instead of parent
@zorab47 , I will setup your gem when I have free time and check if something can be improved.
FYI, I've released a new version with compatibility with ActiveAdmin 1.0.0.