Class: CompletionKit::Api::V1::MetricsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- CompletionKit::Api::V1::MetricsController
- Defined in:
- app/controllers/completion_kit/api/v1/metrics_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/controllers/completion_kit/api/v1/metrics_controller.rb', line 15 def create metric = Metric.new(metric_params) if metric.save render json: metric, status: :created else render json: {errors: metric.errors}, status: :unprocessable_entity end end |
#destroy ⇒ Object
32 33 34 35 |
# File 'app/controllers/completion_kit/api/v1/metrics_controller.rb', line 32 def destroy @metric.destroy! head :no_content end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/completion_kit/api/v1/metrics_controller.rb', line 7 def index render json: Metric.order(created_at: :desc) end |
#show ⇒ Object
11 12 13 |
# File 'app/controllers/completion_kit/api/v1/metrics_controller.rb', line 11 def show render json: @metric end |
#update ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/controllers/completion_kit/api/v1/metrics_controller.rb', line 24 def update if @metric.update(metric_params) render json: @metric else render json: {errors: @metric.errors}, status: :unprocessable_entity end end |