Devise custom after_update_path_for not being called(Rails 4)
devise, ruby, ruby-on-rails, ruby-on-rails-4
Solution
You need to change
put 'users/:id' => 'devise/registrations#update', :as => 'user_registration'
to use your custom `RegistrationsController` controller. So it'll be:
put 'users/:id' => 'registrations#update', :as => 'user_registration'
Problem
I am using devise and want to specify different redirect after updating a user based on a conditional statement. I did follow this https://github.com/plataformatec/devise/wiki/How-To:-Customize-the-redirect-after-a-user-edits-their-profile and it is not calling my custom 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 the skip registrations is because I do not wish to have the new and create routes for the user. I am not sure if the issue is with the routes or something else. Here is the `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 greatly appreciated. This is really stumping me so if anyone has any ideas I would love to try them out.