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.

halfer
  • 19,824
  • 17
  • 99
  • 186
omair azam
  • 520
  • 7
  • 14

2 Answers2

1

Deface is useful when you want to add edit or remove just a part of view ( even controller/s, actions or models)

If you want to change a lot of things, or make it totally different, you dont want Deface, you override the view templates directly.

Obiviously, when you need minor changes you use 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.

krazedkrish
  • 638
  • 3
  • 10
  • yes. Thanks a lot. I have studies and used Deface last night and i also felt so. Deface is just for minor changes. My project is about implementing a whole new theme. I am clear now. Thank. – omair azam Mar 20 '16 at 09:48
0

Yes, you are right in thinking that Deface is for minor additions and adjustments. We run a large eCommerce site that runs on Spree and we have totally overridden the default views to use our theme and layouts on the frontend.

In the backend admin area we have done very little and rely on Deface to add new functionality. For example, we have added extra fields to Spree::Product and to allow admins to edit those fields we use Deface to add them to the product edit page.

Again to bring it home, for huge changes to the base template just copy it and make it your own. For adding or altering portions of the view while keeping the default then use Deface.

ericsaupe
  • 162
  • 3
  • 12
  • Thanks for your response brother. But i would like to discuss it further as i am studying Deface alongside because i have to make a decision about using Deface or editing templates. – omair azam Mar 19 '16 at 17:16
  • With this isn't it possible to implement a completely different Theme by hiding sections you don't want using Deface hooking system and overriding existing ones with your own partials (containing your own html design elements) using Deface and then adding new sections as well using Deface where you want . Isn't it enough flexibility to do anything? – omair azam Mar 19 '16 at 17:22