36 lines
745 B
Ruby
36 lines
745 B
Ruby
class GangsController < ApplicationController
|
|
def index
|
|
json_response Gang.all
|
|
rescue StandardError
|
|
error_response :bad_request
|
|
end
|
|
|
|
def show
|
|
if Gang.count.zero?
|
|
Gang.create.save
|
|
end
|
|
|
|
json_response Gang.first
|
|
end
|
|
|
|
def update
|
|
if gang_params[:chip_scale].to_i.positive?
|
|
Gang.update(gang_params)
|
|
json_response onboarded: true
|
|
else
|
|
error_response :bad_request
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def gang_params
|
|
params.require(:gang).permit :name,
|
|
:chip_name,
|
|
:chip_code,
|
|
:chip_symbol,
|
|
:chip_scale,
|
|
:chip_prefixed
|
|
end
|
|
end
|