关于何时使用 Deface for Spree (Rails) 以及何时不使用的决定?

Decision about when to use Deface for Spree (Rails) and when not?

我正在 Rails 使用 Spree 的电子商务商店。编辑前端有两种方式。

  1. 使用污损
  2. 使用默认视图

我知道通过 Deface 我们有 Spree 升级工具。但是当我考虑使用 Deface 时,我有点困惑,如果它允许我完全宽容地编辑任何 html 元素。

我有一个令人不安的想法,即 Deface 用于小的更改,但如果您必须完全更改前端,则必须使用默认视图进行操作,因为在我的工作地点,他们正在操作默认视图,所以我想到了如果他们正在使用它,则意味着这是优化的解决方案,因为它提供了更大的灵活性。

Deface 是否用于次要覆盖?

我需要专家意见,了解我的个人项目应该使用什么。如果我对此有了清晰的概念,那么我可以指导我办公室的工程师,如果他们做错了。

是的,您认为 Deface 是用于微小的添加和调整的,这是对的。我们 运行 一个大型电子商务网站 运行 在 Spree 上,我们完全覆盖了默认视图以在前端使用我们的主题和布局。

在后台管理区我们做的很少,依靠 Deface 添加新功能。例如,我们向 Spree::Product 添加了额外的字段,并允许管理员编辑这些字段,我们使用 Deface 将它们添加到产品编辑页面。

再次将其带回家,如果要对基本模板进行大量更改,只需将其复制并制作成您自己的。要在保持默认设置的同时添加或更改部分视图,请使用 Deface。

当您只想添加编辑或删除视图的一部分(甚至 controller/s、动作或模型)时,Deface 很有用

如果你想改变很多东西,或者让它完全不同,你不想破坏,你直接覆盖视图模板。

显然,当您需要进行细微改动时,您会使用污损。

Your confusion must be what to do when you need to change more than just minor parts right. If you have to write more than a few deface override statements, it hinders the performance, and also the readability. Its because how deface works is, it first loads the actual template and then deface overrides every time the template is loaded. My suggestion is if you need to modify more than 30% you copy the template from the gem and edit it, instead of using deface.