Show page with HasMany calls the wrong _collection view for the related class
Created by: danbeggan
I believe this has been submitted before and closed but not fixed. https://github.com/thoughtbot/administrate/issues/1183
When viewing a show page for a class with a HasMany relationship it does not render the _collection partial for the associated class, instead it renders the _collection partial of dashboard class.
Lets say you have an author class with a has_many relationship to books, when the books are listed in the authors show page it will use the _collection partial of the author. Most of the time this wont matter, however, if you have modified the _collection partial of author class it will usually throw an error because you are trying to display an attribute on the book that only exists on the author.
To recreate:
- Generate index views for a class (e.g. author) with a has_many relationship.
- Add a custom column to the generated _collection view (views/admin/authors/_collection.html.erb), lets say <% resource.full_address %>
- Include the has_many relationship in the show page of the parent class (books: Field::HasMany) and add it to the SHOW_PAGE_ATTRIBUTES
- Visit the show page of the author and it should throw an error because it is using the _collection partial generated for the author where it is listing the books. Instead it should use the default administrate _collection partial, or if books has _collection partial generated it should use that.