1

I am working on a Rails E-Commerce store using Spree. There are two ways to edit front-end.

  1. using Deface
  2. Working with default views

I know that with Deface we have Spree upgrading facilities. But when I think about using Deface, I am little confused that if it offers me full fledge leniency to edit any html element or not.

I have a disturbing thought that Deface is used for small changes but if you have to completely change the front-end you have to manipulate with default views because at my job place they are manipulating default views, so thought comes that if they are using it then it means this is optimised solution because it offers more flexibility.

Is it true that Deface is for minor overriding?

I need an expert opinion about what to use for my personal project. If I get my concept clear on this then I can guide engineers at my office, if they are doing it the wrong way.

4

2 回答 2

1

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

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

显然,当您需要进行细微更改时,您会使用 deface。

当您需要更改的不仅仅是小部分正确时,您的困惑一定是该怎么做。如果您必须编写多个 deface override 语句,则会影响性能和可读性。这是因为 deface 的工作原理是,它首先加载实际模板,然后在每次加载模板时进行 deface 覆盖。我的建议是,如果您需要修改超过 30%的内容,请从 gem 中复制模板并进行编辑,而不是使用 deface。

于 2016-03-20T06:48:57.037 回答
0

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

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

再次将其带回家,对于基本模板的巨大更改只需复制它并使其成为您自己的。要在保持默认值的同时添加或更改视图部分,请使用 Deface。

于 2016-03-19T16:58:15.983 回答