Class: PushType::Api::AssetsController

Inherits:
PushType::ApiController show all
Defined in:
app/controllers/push_type/api/assets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
# File 'app/controllers/push_type/api/assets_controller.rb', line 21

def create
  if @asset.save
    render :show, status: :created
  else
    render json: { errors: @asset.errors }, status: :unprocessable_entity
  end
end

#destroyObject



37
38
39
40
41
42
43
44
45
# File 'app/controllers/push_type/api/assets_controller.rb', line 37

def destroy
  if @asset.trashed?
    @asset.destroy
    head :no_content
  else
    @asset.trash!
    render :show
  end
end

#emptyObject



52
53
54
55
# File 'app/controllers/push_type/api/assets_controller.rb', line 52

def empty
  PushType::Asset.trashed.destroy_all
  head :no_content
end

#indexObject



9
10
11
# File 'app/controllers/push_type/api/assets_controller.rb', line 9

def index
  @assets = PushType::Asset.not_trash.page(params[:page]).per(12)
end

#restoreObject



47
48
49
50
# File 'app/controllers/push_type/api/assets_controller.rb', line 47

def restore
  @asset.restore!
  render :show
end

#showObject



18
19
# File 'app/controllers/push_type/api/assets_controller.rb', line 18

def show
end

#trashObject



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

def trash
  @assets = PushType::Asset.trashed.page(params[:page]).per(12)
  render :index
end

#updateObject



29
30
31
32
33
34
35
# File 'app/controllers/push_type/api/assets_controller.rb', line 29

def update
  if @asset.update_attributes asset_params
    render :show
  else
    render json: { errors: @asset.errors }, status: :unprocessable_entity
  end
end