forked from makersacademy/acebook-rails-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Devise Custom Redirections
Vijay Kurian edited this page Nov 7, 2019
·
1 revision
in config/routes.rb add
get 'posts' => 'posts#index', as: :user_root
This is a devise method which points a 'get' method to a default view, in this case posts/index.html.erb. This allows the application to redirect the user to the /posts
upon successful Log-in/Sign-up
in app/controllers/posts_controller.rb add
before_action :signed_in
private
def signed_in
redirect_to '/' if !user_signed_in?
end
user_signed_in?
is a default devise method which checks if a user is signed in, returns a boolean.