2

I'm trying to use the devise path /user/sign_out but it's taking me to a user show page with the id sign_out

Processing by UsersController#show as HTML
Parameters: {"id"=>"sign_out"}
Rendered users/show.html.haml within layouts/application (5.0ms)
Completed 500 Internal Server Error in 9ms

This is my routes:

Rails.application.routes.draw do

  devise_for :fans, controllers: { registrations: "fans/devise/registrations"}
  devise_for :users, controllers: { registrations: "users/devise/registrations"}

  devise_scope :fan do
    get '/auth/facebook_fan/callback' => "fans/devise/omniauth_callbacks#facebook"
  end
  devise_scope :artist do
    get '/auth/facebook_artist/callback' => "users/devise/omniauth_callbacks#facebook"
    get '/users/auth/stripe_connect/callback' =>  "users/devise/omniauth_callbacks#stripe_connect"
  end

  resources :about

  resources :rewards, only: :show do 
    resources :pledges, only: [:new, :create, :update]
  end

  resources :users, only: [:show, :index] do
    resources :rewards, only: [:new, :create, :update, :index]
    resources :pledges, only: [:show, :new, :create]
  end
  root "welcome#index"
 end

Where in my routing am I messing things up? Or is it something else?

UsersController:

class UsersController < ApplicationController
  helper_method :user
  respond_to :js

  def index
    respond_to do |format|
      format.html
      format.js
    end
  end

  protected

  def User
    UserPresenter.new(User.find(params[:id]))
  end
end

Registrationscontroller

    class Users::Devise::RegistrationsController < Devise::RegistrationsController
      def update
        # For Rails 4
        account_update_params = devise_parameter_sanitizer.sanitize(:account_update)
        # For Rails 3
        # account_update_params = params[:user]

        # required for settings form to submit when password is left blank
        if account_update_params[:password].blank?
          account_update_params.delete("password")
          account_update_params.delete("password_confirmation")
        end

        @user = User.find(current_user.id)
        if @user.update_attributes(account_update_params)
          set_flash_message :notice, :updated
          # Sign in the user bypassing validation in case their password changed
          sign_in @user, :bypass => true
          redirect_to user_path(@user)
        else
          render "edit"
        end
      end

      def new
        @user = User.new
        respond_to do |format|
          format.html
          format.js
        end
      end
    end

Sign out path and link:

destroy_user_session DELETE /users/sign_out(.:format)                     devise/sessions#destroy

= link_to "Sign out", destroy_user_session_path
4
  • When I try to visit users/sign_out it should destroy the session. Instead it's taking me to a show page with the id sign_out Oct 2, 2014 at 22:38
  • Chances are without seeing the controller is that you're redirecting to the user show path. Can you post some controller code?
    – kobaltz
    Oct 2, 2014 at 22:40
  • Can you post the link with the sign out being called?
    – kobaltz
    Oct 2, 2014 at 22:45
  • 1
    Your signout link should look soemthing like this ` <%= link_to 'Logout', destroy_user_session_path, method: :delete %>`
    – kobaltz
    Oct 2, 2014 at 22:47

1 Answer 1

3

Your signout link should look soemthing like this <%= link_to 'Logout', destroy_user_session_path, method: :delete %>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.