Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将Draper与继承的资源一起使用?
换句话说,如何#decorate为每个资源调用method()?例如@posts对于#index,@post对于#show?
#decorate
@posts
#index
@post
#show
我想过default_scope,但是与 Draper 相关的所有内容都需要在控制器中,而不是在模型中,恕我直言。
default_scope
您可以在 Draper 的 Github 中查看此讨论:
https://github.com/drapergem/draper/issues/99