22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/cms/tasks_controller.rb', line 22
def complete
if params[:task_ids]
Task.all(:conditions => ["id in (?)", params[:task_ids]]).each do |t|
if t.assigned_to == current_user
t.mark_as_complete!
end
end
flash[:notice] = "Tasks marked as complete"
redirect_to dashboard_path
else
@task = Task.find(params[:id])
if @task.assigned_to == current_user
if @task.mark_as_complete!
flash[:notice] = "Task was marked as complete"
end
else
flash[:error] = "You cannot complete tasks that are not assigned to you"
end
redirect_to @task.page.path
end
rescue ActiveRecord::RecordNotFound
flash[:error] = "No tasks were marked for completion"
redirect_to dashboard_path
end
|