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

Overriding the _collection template for a model affects has_many for other models. #549

Closed
hickscorp opened this issue Apr 19, 2016 · 4 comments

Comments

@hickscorp
Copy link

I'm trying to get the index listing for a specific model to show an extra link where the "Edit" and "Destroy" buttons are located. The model name being Foo, I've created a view within app/views/admin/foos/_collection.erb. It works great on the root Foo listing page.

However, an instance of Foo can have many of Bar. When I select a Foo, the detail page shows a list of Bar object there, and unfortunately the same collection template is used.

Is that a bug, or am I missing something?

@hickscorp hickscorp changed the title Overriding the index page for a specific model. Overriding the _collection template for a model affects has_many for other models. Apr 19, 2016
@toobulkeh
Copy link

toobulkeh commented May 27, 2016

It's because the render collection partial looks for the partial via a relative path instead of fully qualified.

How did you solve this problem @hickscorp? I'm debating generalizing that functionality to all models so that it works with all collection partials. (which works for my case -- but not for many other cases)

@hughfm
Copy link
Contributor

hughfm commented May 27, 2016

there's a solution for this issue in #522, which has been working for me...

@hickscorp
Copy link
Author

hickscorp commented May 27, 2016

@toobulkeh no, and we ended up completely rewriting the view. We're thinking about abandoning Administrate for multiple reasons now, one of them being this, the other one being the fact that Administrate is super-confused when asked to sort on "computed columns" (Eg values defined as a getter and a setter on the model, without database counterparts). There should be a flag to tell Administrate about those.

@pablobm
Copy link
Collaborator

pablobm commented Dec 25, 2019

A potential solution for this would be to pass an additional parameter to the _collection partial. I'll be happy to look into a PR providing this (or a different solution).

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

5 participants