Class: PushType::NodesController
- Inherits:
-
AdminController
- Object
- ActionController::Base
- AdminController
- PushType::NodesController
- Defined in:
- app/controllers/push_type/nodes_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #empty ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #position ⇒ Object
- #restore ⇒ Object
- #trash ⇒ Object
- #update ⇒ Object
Methods inherited from AdminController
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/controllers/push_type/nodes_controller.rb', line 21 def create if @node.save flash[:notice] = "#{ @node.type } successfully created." redirect_to redirect_path else render 'new' end end |
#destroy ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/push_type/nodes_controller.rb', line 42 def destroy if @node.trashed? @node.destroy flash[:notice] = "#{ @node.type } permanently deleted." redirect_to redirect_path else @node.trash! flash[:notice] = "#{ @node.type } trashed." redirect_to redirect_path(true) end end |
#edit ⇒ Object
30 31 |
# File 'app/controllers/push_type/nodes_controller.rb', line 30 def edit end |
#empty ⇒ Object
68 69 70 71 72 |
# File 'app/controllers/push_type/nodes_controller.rb', line 68 def empty PushType::Node.trashed.destroy_all flash[:notice] = 'Trash successfully emptied.' redirect_to push_type.nodes_path end |
#index ⇒ Object
9 10 11 12 |
# File 'app/controllers/push_type/nodes_controller.rb', line 9 def index @nodes = node_scope.not_trash.page(params[:page]).per(30) sleep 2 end |
#new ⇒ Object
18 19 |
# File 'app/controllers/push_type/nodes_controller.rb', line 18 def new end |
#position ⇒ Object
54 55 56 57 58 59 60 |
# File 'app/controllers/push_type/nodes_controller.rb', line 54 def position if reorder_node head :ok else render json: @node.errors, status: :unprocessable_entity end end |
#restore ⇒ Object
62 63 64 65 66 |
# File 'app/controllers/push_type/nodes_controller.rb', line 62 def restore @node.restore! flash[:notice] = "#{ @node.type } successfully restored." redirect_to redirect_path end |
#trash ⇒ Object
14 15 16 |
# File 'app/controllers/push_type/nodes_controller.rb', line 14 def trash @nodes = PushType::Node.all.trashed.page(params[:page]).per(30).reorder(deleted_at: :desc) end |
#update ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/controllers/push_type/nodes_controller.rb', line 33 def update if @node.update_attributes node_params.merge(updater: push_type_user) flash[:notice] = "#{ @node.type } successfully updated." redirect_to redirect_path else render 'edit' end end |