Class: Api::BaseController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
lib/generators/petergate_api/templates/app/controllers/api/base_controller.rb

Direct Known Subclasses

V1::AuthController

Instance Method Summary collapse

Instance Method Details

#current_cityObject



13
14
15
# File 'lib/generators/petergate_api/templates/app/controllers/api/base_controller.rb', line 13

def current_city
  @current_city ||= current_user.try(:city)
end

#current_userObject



3
4
5
6
7
8
9
10
11
# File 'lib/generators/petergate_api/templates/app/controllers/api/base_controller.rb', line 3

def current_user
  @user ||= begin
              if (@connection = Api::Connection.find_by(token: request.headers["Authorization"])).present?
                @user = @connection.user
              else
                nil 
              end
            end
end