diff options
Diffstat (limited to 'app/controllers/dashboard/todos_controller.rb')
-rw-r--r-- | app/controllers/dashboard/todos_controller.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index ed11ca5c0eb..4e8ebfb06a0 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -1,6 +1,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController + before_filter :find_todos, only: [:index, :destroy_all] + def index - @todos = TodosFinder.new(current_user, params).execute @todos = @todos.page(params[:page]).per(PER_PAGE) end @@ -13,9 +14,22 @@ class Dashboard::TodosController < Dashboard::ApplicationController end end + 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 } + end + end + private def todo @todo ||= current_user.todos.find(params[:id]) end + + def find_todos + @todos = TodosFinder.new(current_user, params).execute + end end |