Class: Api::V1::PingController

Inherits:
ApiController
  • Object
show all
Defined in:
app/controllers/api/v1/ping_controller.rb

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) asset_exists?(path) (protected)

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
# File 'app/controllers/api/v1/ping_controller.rb', line 17

def asset_exists?(path)
  begin
    pathname = Rails.application.assets.resolve(path)
    return !!pathname # double-bang turns String into boolean
  rescue Sprockets::FileNotFound
    return false
  end
end

- (Object) ping



3
4
5
# File 'app/controllers/api/v1/ping_controller.rb', line 3

def ping
  render json: '{"pong": true}', status: :ok
end

- (Object) pingz



7
8
9
10
11
12
13
# File 'app/controllers/api/v1/ping_controller.rb', line 7

def pingz
  if asset_exists?('zzzz.css')
    render json: '{"pong": true}', status: :ok 
  else
    head :service_unavailable 
  end
end