Permalink
Browse files

guard against double clicks

  • Loading branch information...
anthony committed Mar 15, 2012
1 parent 5faf504 commit 840f012c90d66fc58e01d462ccbb02c0c40b9bfe
Showing with 2 additions and 2 deletions.
  1. +2 −2 app/controllers/project_tasks_controller.rb
@@ -20,7 +20,7 @@ def climate_classification
redirect_to project_task_path(@project_task.task_type, @project_task, path_params)
elsif params[:no_climate_related].present?
flash[:success] = "Thanks! Here is your next document"
- @project_task.not_a_climate_task!
+ @project_task.not_a_climate_task! unless @project_task.not_climate_related? # protect against double click
redirect_to next_project_tasks_path(@project_task.task_type, path_params)
end
end
@@ -79,7 +79,7 @@ def update
success.html do
if params[:completed].present?
flash[:success] = "Thanks! Here is your next document"
- @project_task.completed_by!(current_user)
+ @project_task.completed_by!(current_user) unless @project_task.completed? # double button press?
redirect_to next_project_tasks_path(params[:task_type], path_params)
elsif params[:not_climate_related].present? || params[:incorrect_task_type].present?
flash[:success] = "Thanks! Here is your next document"

0 comments on commit 840f012

Please sign in to comment.