M
M
Max2015-11-27 20:04:24
Ruby on Rails
Max, 2015-11-27 20:04:24

Why did the exit from the Rails site (devise) stop working?

Hello, please tell me how to fix the error. When leaving the site throws out a message - Couldn't find Doctor with 'id'=sign_out and points to a line
@doctor = Doctor.find(params[:id])
in the controller

class DoctorsController < ApplicationController
  before_action :set_doctor, only: [:show, :edit, :update, :destroy]
  def index
    @doctor = Doctor.all
  end

  def show
    @length =  User.where(doctor_id: params[:id]).size
  end

  private 

   def set_doctor
        @doctor = Doctor.find(params[:id])
    end
end

I used to leave the site, but now this option is gone. I use the Devise
UPDATE
routes.rb gem
Rails.application.routes.draw do
  get 'contact/index'

  resources :news
  resources :prices
  get 'healthy/index'
  get 'about/index'

  resources :users
  resources :doctors

  devise_for :doctors, :controllers => { registrations: 'registrations' }
  root 'users#main'
end

Link to exit the session
<%= link_to 'Вийти', destroy_doctor_session_path %>

Update
I solved the problem by moving the line devise_for :doctors, :controllers => { registrations: 'registrations' } to the top of the routes file

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
N. Bekseitov, 2015-11-28
@nbekseitov

Devise - Add sign_in, sign_out, and sign_up links

I
ID25, 2015-11-28
@ID25

add method: :destroy to the link.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question