Fix issue with caching in inventories dropdown [SCI-2776]

This commit is contained in:
Oleksii Kriuchykhin 2019-01-17 15:04:20 +01:00
parent 88cea198f0
commit e62e1873b0
3 changed files with 5 additions and 3 deletions

View file

@ -4,10 +4,12 @@ class MyModuleRepositoryRow < ApplicationRecord
class_name: 'User',
optional: true
belongs_to :repository_row,
optional: true,
inverse_of: :my_module_repository_rows
belongs_to :my_module,
optional: true,
touch: true,
inverse_of: :my_module_repository_rows
belongs_to :my_module, optional: true, inverse_of: :my_module_repository_rows
validates :repository_row, :my_module, presence: true
validates :repository_row, uniqueness: { scope: :my_module }

View file

@ -1,7 +1,7 @@
class RepositoryRow < ApplicationRecord
include SearchableModel
belongs_to :repository, touch: true, optional: true
belongs_to :repository, optional: true
belongs_to :created_by,
foreign_key: :created_by_id,
class_name: 'User',

View file

@ -6,7 +6,7 @@
href="<%= repository_my_module_url(id: @my_module, repository_id: repository) %>"
title="<%= repository.name %>">
<% if enable_counters %>
<% cache [current_user, repository] do %>
<% cache [repository, @my_module] do %>
<%= truncate(repository.name) %>
<span class="assigned-items-counter"><%= "(#{@my_module.repository_rows_count(repository)})" %></span>
<% end %>