Skip to content

WIP: PoC of using a presenter for the `projects#show` view

Rémy Coutable requested to merge 23563-presenters-poc into master

What does this MR do?

This is an example how presenters could be done and used in views to prevent views from directly accessing models' internals.

Notes:

  • no helpers in decorators
  • only data and logic in the presenter
  • explicit delegation is used in this PoC, the upside is that the presenter is not clutered with many unused methods; the downside is that views needs to be able to accept a presenter instance, meaning that the presenter must explicitely delegate all the methods the view is expecting from it. This approach is kind of "dangerous" because views are all over the place, and it's hard to know when a view is given a model or a presenter... We might want to use SimpleDelegator in some cases to ensure we don't get undefined method errors, for instance for the projects#show view shown here.

Related to #23563 (closed).

Merge request reports