Class: PushType::Api::NodesController
- Inherits:
-
PushType::ApiController
- Object
- ActionController::Base
- PushType::ApiController
- PushType::Api::NodesController
- Defined in:
- app/controllers/push_type/api/nodes_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #empty ⇒ Object
- #index ⇒ Object
- #position ⇒ 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/nodes_controller.rb', line 21 def create if @node.save render :show, status: :created else render json: { errors: @node.errors }, status: :unprocessable_entity end end |
#destroy ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/push_type/api/nodes_controller.rb', line 37 def destroy if @node.trashed? @node.destroy head :no_content else @node.trash! render :show end end |
#empty ⇒ Object
60 61 62 63 |
# File 'app/controllers/push_type/api/nodes_controller.rb', line 60 def empty PushType::Node.trashed.destroy_all head :no_content end |
#index ⇒ Object
9 10 11 |
# File 'app/controllers/push_type/api/nodes_controller.rb', line 9 def index @nodes = node_scope.not_trash.page(params[:page]).per(30) end |
#position ⇒ Object
47 48 49 50 51 52 53 |
# File 'app/controllers/push_type/api/nodes_controller.rb', line 47 def position if reorder_node head :no_content else render json: { errors: @node.errors }, status: :unprocessable_entity end end |
#restore ⇒ Object
55 56 57 58 |
# File 'app/controllers/push_type/api/nodes_controller.rb', line 55 def restore @node.restore! render :show end |
#show ⇒ Object
18 19 |
# File 'app/controllers/push_type/api/nodes_controller.rb', line 18 def show end |
#trash ⇒ Object
13 14 15 16 |
# File 'app/controllers/push_type/api/nodes_controller.rb', line 13 def trash @nodes = PushType::Node.all.trashed.page(params[:page]).per(30).reorder(deleted_at: :desc) render :index end |
#update ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/controllers/push_type/api/nodes_controller.rb', line 29 def update if @node.update_attributes node_params_with_fields.merge(updater: push_type_user) render :show else render json: { errors: @node.errors }, status: :unprocessable_entity end end |