ruby/ddl/app/controllers/metric_controller.rb
def create
    # Creates a new metric.
    account = Account.find_by_id(create_params[:account_id])
    unless account
      return render status: 404, json: {error: "Unable to find account with id #{create_params[:account_id]}"}
    end

    metric = account.metrics.new(create_params)
    if metric.save
      render status: 200, json: metric
    else
      render status: 400, json: {error: metric.errors}
    end
  end
# Handles the API for creating metrics and posting data to them.
Handles the API for creating metrics and posting data to them.
Handles the API for creating metrics and posting data to them .
def create
    account = Account.find_by_id(create_params[:account_id])
    unless account
      return render status: 404, json: {error: "Unable to find account with id #{create_params[:account_id]}"}
    end
    metric = account.metrics.new(create_params)
    if metric.save
      render status: 200, json: metric
    else
      render status: 400, json: {error: metric.errors}
    end
  end
def create account = Account . find_by_id ( create_params [ :account_id ] ) unless account return render status : 404 , json : { error : "Unable to find account with id #{create_params[:account_id]}" } end metric = account . metrics . new ( create_params ) if metric . save render status : 200 , json : metric else render status : 400 , json : { error : metric . errors } end end
Handles the API for creating metrics and posting data to them.
Handles the API for creating metrics and posting data to them .
# Creates a new metric.