ruby-on-rails-4erbspreedeface

Rails spree : How to override login partial using deface?


I'm trying to override login page in spree using deface, but I can't access the login partial using the following code

Deface::Override.new(
:virtual_path => 'spree/shared/_login',
:name => 'override login',
:replace=> "body",
:text=> "<body><h1>loin<h1></body>",
:disabled => false
)

How ever this seems not to work for some reason, in the server output I get : Deface: 1 overrides found for 'spree/shared/_login' Deface: 'override login' matched 0 times with 'body' Rendered /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spree_auth_devise-3.1.0/lib/views/frontend/spree/shared/_login.html.erb (50.3ms) Rendered /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spree_auth_devise-3.1.0/lib/views/frontend/spree/user_sessions/new.html.erb within spree/layouts/spree_application (77.4ms)

I tried multiple selectors for css in the page with no result, I noticed the login partial is located in 'spree_auth_devise-3.1.0' sub directory 'not spree_frontend-3.1.0' as the rest of them, does anyone now how to deface the login page in spree or how to reference the right path for its partial ?


Solution

  • If you would like to replace all body, better override partial and not use Deface. It is great tool but not when you want to do so big change. Error means that it not found body in partial, and thats true because there is no body. You can use only

    <%= form_for Spree::User.new, :as => :spree_user, :url => spree.create_new_session_path do |f| %>
      <div id="password-credentials">
        <p>
          <%= f.label :email, Spree.t(:email) %>
          <%= f.email_field :email, :class => 'form-control', :tabindex => 1, autofocus: true %>
        </p>
        <p>
          <%= f.label :password, Spree.t(:password) %>
          <%= f.password_field :password, :class => 'form-control', :tabindex => 2 %>
        </p>
      </div>
      <p>
        <%= f.check_box :remember_me, :tabindex => 3 %>
        <%= f.label :remember_me, Spree.t(:remember_me) %>
      </p>
    
      <p><%= f.submit Spree.t(:login), :class => 'btn btn-lg btn-success btn-block', :tabindex => 4 %></p>
    <% end %>