I want to redirect an inactive user to the registration path in order to collect some information. Here are two approaches I took, but none of them work:
I redefined the method of the after_sign_in_path method as follows (in application_controller.rb ):
def after_sign_in_path_for(resource) debugger if(account_active) return root_path; else return edit_user_registration_path(resource) end end
When I hooked the code up to the debugger, I see that devise calls call_sign_in_path_for. In addition, this call is generated by the correct URL:
(rdb:2) after_sign_in_path_for(resource) "/users/edit.1"
However, when I look at the server logs, no attempt is made to redirect to "/users/edit.1" under any circumstances.
I tried to move the above application_helper.rb method , session_controller.rb (by extension Devise :: SessionController) and session_helper.rb
The problem is that devise calls this method to retrieve the url but never tries to redirect. I checked the web server logs and the development method jumps directly to user_root url.
Here is the appropriate development configuration from .rb routes:
devise_for :users do resource :registration, only: [:new, :create, :edit, :update], path: 'users', path_names: { new: 'sign_up' }, controller: 'devise/registrations', as: :user_registration do get :cancel end root :to => "home#index" end match '/user' => "products#index", :as => 'user_root'
Any suggestions on what I should try?
Thanks,
Tabrez