ruby on rails - Devise Redirect to Page After Sign In Admin -


i on rails 4.

i have setup when user signs or logs in (devise) redirect page last on. works nicely.

however, having trouble figuring out how ignore admin completely. when signing in admin (admin own model), receive redirect loop, wants go previous page , admin panel @ same time.

here application_controller:

after_filter :store_location    def store_location     # store last url long isn't /users path     session[:previous_url] = request.fullpath unless request.fullpath =~ /\/users/    end    def after_sign_in_path_for(resource)     session[:previous_url] || root_path   end 

what best way ignore after_sign_in_path_for if admin signing in?

we need supply on route or since creating such method in our application_controller. simple solution 1 below.

def after_sign_in_path_for(resource)   if resource.admin? #assuming there such function     root_path   else     session[:previous_url] || root_path   end end 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -