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

Remove the need for resource index path #1371

Closed
wants to merge 1 commit into from

Conversation

0urobor0s
Copy link

This removes the need to have an index path if you have a resource that only has a show path requirement

@purinkle
Copy link
Contributor

purinkle commented Aug 9, 2019

Would you be able to give a more concrete example of where you may need this?

Is it something that can be controlled by customising the dashboard?

@0urobor0s
Copy link
Author

Let's say you have a resource A that has many resources B. When I enter the show page for A I want to see all Bs that belong to A and also see the show page for B without having the index page for B.

namespace :admin do
  resources :a
  resources :b, only: [:show]
end

@robinboening
Copy link

👍 This is much simpler than my approach #1418 and solves the same issue.

@0urobor0s
Copy link
Author

@purinkle ping

@pablobm
Copy link
Collaborator

pablobm commented Dec 28, 2019

Hello @0urobor0s, thank you for your PR and apologies for the delay.

There are two helpers that I think can be used instead of Rails.application.routes.url_helpers.method_defined?.

One is valid_action?, which checks if the route exists (similar to your line), and then there's show_action?, which checks if the user is authorised to see it (if using Pundit as per the docs).

So I think the line could instead be valid_action?(:index, resource) && show_action?(:index, resource).

Also, we'd need a spec for this. Perhaps one around payments only showing as a has_many of orders? (As per the current example app and feature specs).

@nickcharlton nickcharlton added dashboards how administrate presents fields and displays data feature new functionality that’s not yet implemented labels Jan 2, 2020
@pablobm
Copy link
Collaborator

pablobm commented Jan 30, 2020

Fixed at #1524

@pablobm pablobm closed this Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dashboards how administrate presents fields and displays data feature new functionality that’s not yet implemented
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants