Class: PushType::NodesController

Inherits:
AdminController show all
Defined in:
app/controllers/push_type/nodes_controller.rb

Instance Method Summary collapse

Methods inherited from AdminController

#info

Instance Method Details

#createObject



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

#destroyObject



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

#editObject



30
31
# File 'app/controllers/push_type/nodes_controller.rb', line 30

def edit
end

#emptyObject



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

#indexObject



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

#newObject



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

def new
end

#positionObject



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

#restoreObject



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

#trashObject



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

#updateObject



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