Skip to content

Instantly share code, notes, and snippets.

@0ex-d
Created February 2, 2017 01:16
Show Gist options
  • Save 0ex-d/aa43fd615056aec128aeecf3b42bd6ba to your computer and use it in GitHub Desktop.
Save 0ex-d/aa43fd615056aec128aeecf3b42bd6ba to your computer and use it in GitHub Desktop.
Simple Login Logic in Rails
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