Class: Cats::Core::ApplicationController

Inherits:
ActionController::API
  • Object
show all
Defined in:
app/controllers/cats/core/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#authenticateObject



13
14
15
# File 'app/controllers/cats/core/application_controller.rb', line 13

def authenticate
  render json: {error: "Unauthorized"}, status: 401 if current_user.nil?
end

#current_userObject



6
7
8
9
10
11
# File 'app/controllers/cats/core/application_controller.rb', line 6

def current_user
  return if token.nil?

  user = User.find(auth["id"])
  @current_user ||= user
end

#skip_bulletObject

In case we want to disable bullet for specific controller actions



18
19
20
21
22
23
24
# File 'app/controllers/cats/core/application_controller.rb', line 18

def skip_bullet
  previous_value = Bullet.enable?
  Bullet.enable = false
  yield
ensure
  Bullet.enable = previous_value
end