This line: <% if policy(options[:class_name].constantize).index? %> will try to lookup the policy for Widget instead of Admin::Widget.
Additionally, the code that generates the hyperlink: "#{@resource_class.name.underscore}_#{name}_path" will resolve to admin/owner_widgets_path instead of the correct path: owner_widgets_path.
I am able to override both methods by overriding_breadcrumb_actions.html.erb with the below code:
<% if policy("#{engine_wrapper.namespace}::#{options[:class_name]}".constantize).index? %>
<li>
<%= link_to(options[:class_name].constantize.model_name.human(count: 2),
send("#{@resource_class.name.demodulize.underscore}_#{name}_path", @resource)) %>
</li>
<% end %>
Happy to open a PR but wanted to see if there is a more elegant solution to this - particularly since I suspect that my approach will cause problems for a non-namespaced installation.
After upgrading to Godmin 2.0, I'm not able to edit or show resources with nested resources:
Specifically, there is an issue within
_breadcrumb_actions.html.erb
that is not properly looking up the Pundit policies for the nested resource.https://github.com/varvet/godmin/blob/3334ff04c20826ca2ac5e055f0deb43d53e091a7/app/views/godmin/resource/_breadcrumb_actions.html.erb#L31-L38
This line:
<% if policy(options[:class_name].constantize).index? %>
will try to lookup the policy forWidget
instead ofAdmin::Widget
.Additionally, the code that generates the hyperlink:
"#{@resource_class.name.underscore}_#{name}_path"
will resolve toadmin/owner_widgets_path
instead of the correct path:owner_widgets_path
.I am able to override both methods by overriding
_breadcrumb_actions.html.erb
with the below code:Happy to open a PR but wanted to see if there is a more elegant solution to this - particularly since I suspect that my approach will cause problems for a non-namespaced installation.