Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change name of the 'current_user' helper in Devise

I have a Client model setup with Devise, and I've namespaced the routes like this:

  namespace :portal do
    devise_for :clients, controllers: {
        sessions: 'clients/sessions',
        registrations: 'clients/registrations',
        invitations: 'clients/invitations'
    } 
   end

Because of this, instead of a current_client helper I get current_portal_client. Is there a way I can set it to current_client? Should I just alias it in ApplicationController or is there a Devise specific way?

like image 852
domi91c Avatar asked Sep 15 '25 21:09

domi91c


1 Answers

Devise builds those methods on the fly and adds them to ActiveSupport on load. See line 132 here: https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/helpers.rb, so overriding the default functionality might be tricky and could get ugly fast.

Since Devise doesn't appear to offer any easily configurable overrides, you're probably better off writing an alias method in your ApplicationController as you suggested.

like image 92
NM Pennypacker Avatar answered Sep 19 '25 16:09

NM Pennypacker