Rails : Deface : Debugging techniques

If you are not sure the path for the partial/template is correct then you can verify using this technique

$ rake deface:get_result['spree/shared/_link_to_account']
=> ActionView::MissingTemplate: Missing template

$ rake deface:get_result['spree/shared/_login_bar']
# ---------------- Before ----------------
# <% if spree_current_user %>
#   <li><%= link_to Spree.t(:my_account), spree.account_path %></li>
#   <li><%= link_to Spree.t(:logout), spree.logout_path %></li>
# <% else %>

You can even verify the selectors, like

$ rake deface:test_selector['spree/shared/_login_bar , li']
# Querying 'spree/shared/_login_bar' for 'li'
# ---------------- Match 1 ----------------
# <li>
# <%= link_to 'Dashboard', '/admin' if spree_current_user.is_admin? %> </li>
# ---------------- Match 2 ----------------

Moreover, if the error persists even after the selector has been verified, then you have to make sure the text you are going to replace with does not contain any syntax/runtime error.

When do we need to  restart the server?

No need to restart the server every time you make changes in overrides.

Yes, You should if you have set config.deface.enabled = false; normally we set this in production.rb and in that case you should precompile the overrides. See this for more info

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s