Fix usage of task_params in TasksController
This commit is contained in:
parent
f15ca8610b
commit
640e230d88
1 changed files with 5 additions and 4 deletions
|
@ -17,7 +17,8 @@ class TasksController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@task = Task.new(task_params, current_user_id: current_user.id)
|
@task = Task.new(current_user_id: current_user.id)
|
||||||
|
@task.attributes=(task_params)
|
||||||
if params[:periodic]
|
if params[:periodic]
|
||||||
@task.periodic_task_group = PeriodicTaskGroup.new
|
@task.periodic_task_group = PeriodicTaskGroup.new
|
||||||
end
|
end
|
||||||
|
@ -45,7 +46,7 @@ class TasksController < ApplicationController
|
||||||
was_periodic = @task.periodic?
|
was_periodic = @task.periodic?
|
||||||
prev_due_date = @task.due_date
|
prev_due_date = @task.due_date
|
||||||
@task.current_user_id = current_user.id
|
@task.current_user_id = current_user.id
|
||||||
@task.attributes=(params[:task])
|
@task.attributes=(task_params)
|
||||||
if @task.errors.empty? && @task.save
|
if @task.errors.empty? && @task.save
|
||||||
task_group.update_tasks_including(@task, prev_due_date) if params[:periodic]
|
task_group.update_tasks_including(@task, prev_due_date) if params[:periodic]
|
||||||
flash[:notice] = I18n.t('tasks.update.notice')
|
flash[:notice] = I18n.t('tasks.update.notice')
|
||||||
|
@ -89,7 +90,7 @@ class TasksController < ApplicationController
|
||||||
redirect_to user_tasks_path, :notice => I18n.t('tasks.accept.notice')
|
redirect_to user_tasks_path, :notice => I18n.t('tasks.accept.notice')
|
||||||
end
|
end
|
||||||
|
|
||||||
# deletes assignment between current_user and given task
|
# deletes assignment between current_user and given taskcurrent_user_id: current_user.id
|
||||||
def reject
|
def reject
|
||||||
Task.find(params[:id]).users.delete(current_user)
|
Task.find(params[:id]).users.delete(current_user)
|
||||||
redirect_to :action => "index"
|
redirect_to :action => "index"
|
||||||
|
@ -118,7 +119,7 @@ class TasksController < ApplicationController
|
||||||
def task_params
|
def task_params
|
||||||
params
|
params
|
||||||
.require(:task)
|
.require(:task)
|
||||||
.permit(:name, :description, :duration, :user_list, :required_users, :workgroup, :due_date, :done)
|
.permit(:name, :description, :duration, :user_list, :required_users, :workgroup_id, :due_date, :done)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue