Invent custom after_update_path_for not called (Rails 4)

I am using devise and want to specify a different redirect after updating the user based on the conditional statement. I did this https://github.com/plataformatec/devise/wiki/How-To:-Customize-the-redirect-after-a-user-edits-their-profile and does not call my after_update_path_for method.

routes.rb

devise_for :users, :skip => [:registrations], :controllers => { :registrations => :registrations }

as :user do
  get 'users/edit' => 'devise/registrations#edit', :as => 'edit_user_registration'    
  put 'users/:id' => 'devise/registrations#update', :as => 'user_registration'            
end

The reason I have a badge registration is because I do not want to have new passes and create routes for the user. I am not sure if the problem is with routes or something else.

Here registrations_controller.rb

class RegistrationsController < Devise::RegistrationsController
  protected
    def after_update_path_for(resource)
      binding.pry
      if current_user.position == "owner" && current_user.sign_in_count == 1
        hub_landing_path
      end
    end
end

Any help is appreciated. It really shocks me, so if anyone has any ideas that I would like to try.

+4
2

put 'users/:id' => 'devise/registrations#update', :as => 'user_registration'

RegistrationsController. :

put 'users/:id' => 'registrations#update', :as => 'user_registration'
+5

@NARKOZ Rails 4. Devise :

# users/passwords_controller.rb
class Users::PasswordsController < Devise::PasswordsController
 protected
 def after_resetting_password_path_for(resource)
  signed_in_root_path(resource)
 end
end

: https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in

0

All Articles