Topic: Using devise, how do you route to and after login?

Using rails 3.2.5 and devise 2.1.0

I've looked at so many posts and web pages about this that I probably wouldn't recognize the answer if it was placed in front of me, but my questions are these:

How do I make the login page the root of my (internal usage only) app?
I tried adding to my routes.rb file:
root :to => <%= link_to('login, new_user_session_path) %>
but this results in an error from the server: "Unexpected '<' ..."

How do I route the user after login?  I need to send them to, for example employee 10119, to '/employee/10119/timecard'.  Everything I have read assumes the user will try to access a restricted page, Devise will log them in then send them to the page they were trying to get to.  I want to send the user to their specific timecard page after logging in.

Any ideas?  Thanks.  --Fred

Re: Using devise, how do you route to and after login?

In your ApplicationController create a method called after_sign_in_path_for.  This method should return the path that you want to the user to go to. I believe the user is passed as the first param to this method too.

Last edited by themusicman (2012-07-05 18:04:41)

Re: Using devise, how do you route to and after login?

You should really look into the devise wiki. It's a complicated gem and worth reading the docs. You can find your answer here: https://github.com/plataformatec/devise … ign-in-out

I'm a Phoenix Ruby on Rails developer currently available for freelance work.