2

I am trying to override the devise controller but my changes don't have any affects.

this is my sessions_controller.rb for example

class Users::SessionsController < Devise::SessionsController
  # before_action :configure_sign_in_params, only: [:create]

  # GET /resource/sign_in
   def new
     super
     authorize! :new, @user
   end

  # POST /resource/sign_in
   def create
     super
     authorize! :create, @user
   end

  # DELETE /resource/sign_out
  # def destroy
  #   super
  # end

  # protected

  # If you have extra params to permit, append them to the sanitizer.
  # def configure_sign_in_params
  #   devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
  # end
end

this should take the def new of the 'normal' sessions controller and add the 2nd line to it.

the link of the original session_controller on github

and this is my routes.rb

    Rails.application.routes.draw do
  resources :sessions
  resources :corsin_lists
  resources :fileuploads do
    collection { post :import }
  end

  root 'documents#index'
  resources :documents
  resources :entries

  resources :documents do
    member do
      get :entries
    end
  end
  devise_for :users, :controllers => {:sessions => "users_sessions"}
end
aschmid
  • 229
  • 3
  • 12
  • Could you post your session controller code? – M_G Aug 24 '16 at 12:18
  • i generated this with rails generate devise:controllers. and the authorize lines are from myself (for cancancan) – aschmid Aug 24 '16 at 12:21
  • There's plenty documentation on how to do this on devise wiki page – lcguida Aug 24 '16 at 13:10
  • Possible duplicate of [Override devise registrations controller](http://stackoverflow.com/questions/3546289/override-devise-registrations-controller) – user1201917 Aug 24 '16 at 13:22
  • Were you able to solve this? I have the exact same issue with the edit action in the registrations_controller. The controllers are overridden properly, that's not the issue. The issue is that the cancancan authorizations on these overridden controllers seem to have no effect. – Augusto Samamé Barrientos Jul 11 '17 at 17:42

0 Answers0