Created
February 2, 2017 01:16
-
-
Save 0ex-d/aa43fd615056aec128aeecf3b42bd6ba to your computer and use it in GitHub Desktop.
Simple Login Logic in Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthController < ApplicationController | |
before_action :is_user_authenticated | |
def is_user_authenticated | |
unless current_user | |
flash[:alert] = "Please log in" | |
redirect_to new_user_session_path | |
end | |
end | |
# Usage | |
class BookingController < AuthController | |
def index | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment