ruby-on-railsspreedeface

Spree/Deface - Conditionally set an override


Is there a way to conditionally set a deface override, for example based on product?

So product == 'x', then do it, otherwise, ignore.


Solution

  • Your best bet will be to conditionally use render_original like so:

    Deface::Override.new(:virtual_path => "products", 
                         :name => "example", 
                         :surround => "div#products",
                         :text => "<% if @product == 'x' %><%# do something %><% else %><%= render_original %><% end %>")