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
  • !89

Revert "single controller for all resources"

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge gw-multiple-controllers into master Sep 18, 2015
  • Overview 1
  • Commits 1
  • Pipelines 0
  • Changes 10

Created by: gracewashere

This reverts commit 267edf27.

There are two ways to handle the controller layer for Administrate:

  1. Generate a single controller, Admin::ApplicationController, and route the RESTful actions for all resource types through it. Let users subclass the controller to create resource-specific behavior.
  2. Generate Admin::ApplicationController, which contains all of the default RESTful logic, as well as empty subclasses for each resource type. If users want to customize controller actions in the future, this saves them a generator step.

We originally went with option 2, before switching to option 1 in 267edf27.

That switch came in the wake of adding Administrate to Hound. We decided to change to a single controller to reduce the diff noise from the administrate:install generator.

Recently, we've started adding Administrate to Upcase. Upcase is a more complex application, and needs more customization off the bat. After attempting several customizations, it's clear that it would be much cleaner/easier to customize if the relevant controller subclasses had been pre-generated.

Some examples of customizations we've needed to make are:

  • defining custom resource finders (e.g. to look up a product by a slug)
  • overriding a view for a single resource type (Rails needs the subclass chain to look up the correct view to render)

This change also makes routing significantly cleaner, letting us use the resources method without additional arguments.

Many of these problems could be solved by taking option 1, and writing very good documentation & controller/view generators, but as an MVP I believe it's cleaner and clearer for developers to explicitly define the controller subclasses up front.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: gw-multiple-controllers