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
  • Merge requests
  • !381

Associate fields with original resource

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/phusion/associate_field_with_resource into master Jan 07, 2016
  • Overview 3
  • Commits 1
  • Pipelines 0
  • Changes 12

Created by: FooBarWidget

This pull request adds a resource field to the Field class. This gives more flexibility to field views, allowing it to customize its display based on the original resource. For example, this will allow fields to display content based on two different columns.

My use case is as follows. My system has many Products. Each Product has a name (which is an internal name) and an optional display_name. I want to display the product name as follows:

product name here
(optional display name here) <--- this line is only shown if display_name is not nil

With this pull request, I'm able to write a view like this:

<%= field.resource.name %>
<% if field.resource.display_name %>
  <br>
  <small><%= field.resource.display_name %></small>
<% end %>
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/phusion/associate_field_with_resource