Peter Boomsma
Peter Boomsma

Reputation: 9808

Use devise to route to specific url

When a user who is not signed in visits my homepage he gets redirected to users/sign_inwhich has a sign in form. When the user signs in he gets redirected to the root of the page. http://localhost:3000/#/_=_

But I want user to be redirected to this url http://localhost:3000/#/home

I've found this on the Devise page.

def after_sign_in_path_for(resource)
  current_user_path
end

But I'm not sure how I should change this code to get devise to redirect my users to http://localhost:3000/#/home which corrosponds to a router-ui state.

  .state('home', {
    url: '/home',
    templateUrl: '../assets/angular-app/templates/_home.html.haml',
    controller: 'mainCtrl',
    resolve: {
      postPromise: ['posts', function(posts){
        return posts.getAll();
      }]
    }
  })

Upvotes: 0

Views: 41

Answers (1)

Sajjad Murtaza
Sajjad Murtaza

Reputation: 1504

Try this in your Application Controller

def after_sign_in_path_for(resource)
   "your_path_here"

end

for example if you want to go to root_path then "your_path_here" = root_path

Upvotes: 1

Related Questions