Class: Workflow::User::TasksController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/workflow/user/tasks_controller.rb

Instance Method Summary collapse

Instance Method Details

#assignedObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/workflow/user/tasks_controller.rb', line 4

def assigned
  @tasks = Task.includes(:story).where(user_id: current_user.id, state: 'assigned')
  projects = Project.where(id: @tasks.map{|t| t.story.project_id }).index_by(&:id)
  products = Product.where(id: projects.values.map(&:product_id)).index_by(&:id)
  
  @tasks.map! do |task|
    project = projects[task.story.project_id]
    project.product = products[project.product_id]
    task.story.project = project
    task
  end
  
  render layout: false if request.xhr?
end