Class: Dashboard::TodosController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/dashboard/todos_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/dashboard/todos_controller.rb', line 8

def destroy
  todo.done

  todo_notice = 'Todo was successfully marked as done.'

  respond_to do |format|
    format.html { redirect_to dashboard_todos_path, notice: todo_notice }
    format.js { render nothing: true }
    format.json do
      render json: { count: @todos.size, done_count: current_user.todos.done.count }
    end
  end
end

#destroy_allObject


22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/dashboard/todos_controller.rb', line 22

def destroy_all
  @todos.each(&:done)

  respond_to do |format|
    format.html { redirect_to dashboard_todos_path, notice: 'All todos were marked as done.' }
    format.js { render nothing: true }
    format.json do
      find_todos
      render json: { count: @todos.size, done_count: current_user.todos.done.count }
    end
  end
end

#indexObject


4
5
6
# File 'app/controllers/dashboard/todos_controller.rb', line 4

def index
  @todos = @todos.page(params[:page])
end