summaryrefslogtreecommitdiff
path: root/app/controllers/dashboard/todos_controller.rb
blob: e24b8d3e58f55f03817593b214f53e1a837bd5f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Dashboard::TodosController < Dashboard::ApplicationController
  def index
    @todos = TodosFinder.new(current_user, params).execute
    @todos = @todos.page(params[:page]).per(PER_PAGE)
  end

  def destroy
    todo.done!

    respond_to do |format|
      format.html { redirect_to dashboard_todos_path, notice: 'Todo was successfully marked as done.' }
      format.js { render nothing: true }
    end
  end

  private

  def todo
    @todo ||= current_user.todos.find(params[:id])
  end
end