Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Issues
  • #2049
Closed
Open
Issue created Oct 13, 2021 by Administrator@rootContributor

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.
Assignee
Assign to
Time tracking