in applicationcontroller, according devise docs, how to: redirect specific page on successful sign in , sign out, case switch when can not reached, in pry debugging console, shows 'resource.class == user true'. don't know part of rails processing missed, hint appreciated!
# applicationcontroller.rb class applicationcontroller < actioncontroller::base # prevent csrf attacks raising exception. # apis, may want use :null_session instead. protect_from_forgery with: :exception protected def after_sign_in_path_for(resource) # check class of object determine type binding.pry case resource.class when user puts "user redirect ==== " return session.delete(:return_to) || current_user_path else puts "super call ....." super end end end
you pretty close. need resource class name using resource.class.name
, can compare string such 'user'
nothing class name.
def after_sign_in_path_for(resource) # check class of object determine type binding.pry case resource.class.name #=>this return class name i.e 'user' when 'user' puts "user redirect ==== " return session.delete(:return_to) || current_user_path else puts "super call ....." super end end
Comments
Post a Comment