oivoodoo / devise_masquerade

Extension for devise, enable login as functionality. Add link to the masquerade_path(resource) and use it.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No route matches [POST] "/masquerade/back"

bgilbank opened this issue · comments

Not sure why I am getting this error?

No route matches [POST] "/masquerade/back"

class Users::MasqueradesController < Devise::MasqueradesController
  protected

  def find_resource
    masqueraded_resource_class.friendly.find(params[:id])
  end

  def after_masquerade_path_for(resource)
    dashboard_users_path
  end

  def after_back_masquerade_path_for(resource)
    dashboard_users_path
    flash[:notice] = 'Masquerade session has ended'
  end
end

Users Index View

 <%= link_to "View", masquerade_path(user) %>

application.html.erb

<% if user_masquerade? %>
 <p class="">You are now logged in as <%= current_user.name %>!<p>
 <%= button_to "Reverse masquerade", back_masquerade_path(current_user), class: "btn btn__pill" %>
<% end %>

Used button_to instead of link_to. Works fine now with link_to