Add created_by user to Task
This commit is contained in:
parent
18e38be6be
commit
b6f5295267
10 changed files with 35 additions and 7 deletions
|
|
@ -18,6 +18,7 @@ class TasksController < ApplicationController
|
|||
|
||||
def create
|
||||
@task = Task.new(current_user_id: current_user.id)
|
||||
@task.created_by = current_user
|
||||
@task.attributes=(task_params)
|
||||
if params[:periodic]
|
||||
@task.periodic_task_group = PeriodicTaskGroup.new
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ class Task < ApplicationRecord
|
|||
has_many :users, :through => :assignments
|
||||
belongs_to :workgroup
|
||||
belongs_to :periodic_task_group
|
||||
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_user_id'
|
||||
|
||||
scope :non_group, -> { where(workgroup_id: nil, done: false) }
|
||||
scope :done, -> { where(done: true) }
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@
|
|||
%dl.dl-horizontal
|
||||
%dt= heading_helper Task, :name
|
||||
%dd= @task.name
|
||||
%dt= heading_helper Task, :created_on
|
||||
%dd= format_time @task.created_on
|
||||
%dt= heading_helper Task, :created_by
|
||||
%dd= show_user @task.created_by
|
||||
- if @task.description.present?
|
||||
%dt= heading_helper Task, :description
|
||||
%dd= simple_format(@task.description)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue