Class: Workflow::User::StoriesController

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

Instance Method Summary collapse

Instance Method Details

#indexObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/workflow/user/stories_controller.rb', line 2

def index
  @stories = Story.where(state: 'active', :users_without_tasks_ids.ne => current_user.id).paginate(page: params[:page], per_page: 20)
  projects = Project.where(id: @stories.map(&:project_id)).index_by(&:id)
  products = Product.where(id: projects.values.map(&:product_id)).index_by(&:id)
  
  @stories.map! do |story|
    projects[story.project_id].product = products[projects[story.project_id].product_id]
    story.project = projects[story.project_id]
    story
  end
  
  render layout: false if request.xhr?
end