Wrote ensure_logged_in method in application_controller.rb