Skip to content

Resource show

Mattia Roccoberton edited this page May 16, 2023 · 3 revisions

A resource show page expose the details of an item extracted using a Repository.

Here is an example (check the show key):

sections:
  - slug: posts
    name: Posts
    type: resource
    model: Post
    show:
      attributes:
        - id
        - title: downcase
        - description
        - field: author_id
          header: The author
          link_to: authors
          call: author, name
        - category: upcase
        - published
        - state: downcase
        - position: format, %f
        - created_at: strftime, %Y%m%d %H:%M
      widgets:
        - Admin::PopularAuthorsWidget

Show keys

  • attributes (Array): list of fields to expose
  • widgets (Array): list of widgets (as classes) to show at the bottom of the page

attributes

Every element of the attributes array can be:

  • a string with the field (ex. created_at)
  • a hash with a single element: field: transform_method (es. first_name: upcase)
  • a hash with more options, ex.
  - field: customer_id
    link_to: customers
Clone this wiki locally