Class: Maglev::Api::AssetsController

Inherits:
Maglev::ApiController show all
Includes:
ActiveStorage::SetCurrent
Defined in:
app/controllers/maglev/api/assets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
# File 'app/controllers/maglev/api/assets_controller.rb', line 18

def create
  asset = resources.create!(asset_params)
  head :created, location: api_asset_path(asset), maglev_asset_id: asset.id
end

#destroyObject



28
29
30
31
# File 'app/controllers/maglev/api/assets_controller.rb', line 28

def destroy
  resources.find(params[:id]).destroy!
  head :no_content
end

#indexObject



8
9
10
11
12
# File 'app/controllers/maglev/api/assets_controller.rb', line 8

def index
  @assets = resources.search(
    params[:query], params[:asset_type], params[:page], params[:per_page]
  )
end

#showObject



14
15
16
# File 'app/controllers/maglev/api/assets_controller.rb', line 14

def show
  @asset = resources.find(params[:id])
end

#updateObject



23
24
25
26
# File 'app/controllers/maglev/api/assets_controller.rb', line 23

def update
  resources.find(params[:id]).update!(asset_params)
  head :ok
end