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
  • #245
Closed
Open
Issue created Nov 16, 2015 by Administrator@rootContributor

Polymorphic field should override dashboard selection from Associative

Created by: monkbroc

Currently Polymorphic is only an alias for Associative.

Associative#associated_dashboard uses the attribute name to select the correct dashboard.

In Polymorphic this leads to a uninitialized constant error when calling field.display_associated_resource during the render of app/views/fields/polymorphic/_index.html.erb

For a polymorphic relation, the correct dashboard should be taken from the class of the associated object if it exists.

My workaround right now is:

<% if field.data %>
  <%= link_to(
    "#{field.data.class.name}Dashboard".constantize.new.display_resource(field.data),
    polymorphic_path([:admin, field.data])
  ) %>
<% end %>

Do you agree with the approach? Is there a better way to get the associated dashboard name?

I can clean this up and make a PR for this.

Assignee
Assign to
Time tracking