Ruby on Rails patterns - decorator vs presenter

前端 未结 2 904
刺人心
刺人心 2020-12-07 09:27

There is all sorts of talk lately in the Ruby on Rails community about decorators and presenters.

What is the essential difference between the two? If there is, what

2条回答
  •  我在风中等你
    2020-12-07 09:56

    A decorator is more of a "let's add some functionality to this entity". A presenter is more of a "let's build a bridge between the model/backend and view". The presenter pattern has several interpretations.

    Decorators are generic/general purpose. Presenters have a narrower range of responsibilities/uses. Decorators are used across domains, presenters are almost always related to view-like functionality.

    • Draper site
    • RailsCasts Draper Episode

提交回复
热议问题