Class: PushType::Api::AssetsController
- Inherits:
-
PushType::ApiController
- Object
- ActionController::Base
- PushType::ApiController
- PushType::Api::AssetsController
- Defined in:
- app/controllers/push_type/api/assets_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #empty ⇒ Object
- #index ⇒ Object
- #restore ⇒ Object
- #show ⇒ Object
- #trash ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#empty ⇒ Object
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 |
#index ⇒ Object
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 |
#restore ⇒ Object
47 48 49 50 |
# File 'app/controllers/push_type/api/assets_controller.rb', line 47 def restore @asset.restore! render :show end |
#show ⇒ Object
18 19 |
# File 'app/controllers/push_type/api/assets_controller.rb', line 18 def show end |
#trash ⇒ Object
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 |
#update ⇒ Object
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 |