upgrade pat3
This commit is contained in:
+10
-5
@@ -56,21 +56,26 @@ class Table
|
||||
if tables.is_a?(Array)
|
||||
lists = List.active_for_table(tables.map(&:id))
|
||||
for table in tables
|
||||
table.active_list_id = lists.find{|l| l.table_id == table.id}.try(:id)
|
||||
if list = lists.find{|l| l.table_id == table.id}
|
||||
table.active_list_id = list.id
|
||||
table.active_list = list
|
||||
end
|
||||
end
|
||||
tables
|
||||
else
|
||||
table = tables
|
||||
list = List.active_for_table(table).first
|
||||
table.active_list_id = list.id if list.present?
|
||||
if list = List.active_for_table(table).first
|
||||
table.active_list_id = list.id
|
||||
table.active_list = list
|
||||
end
|
||||
table
|
||||
end
|
||||
end
|
||||
|
||||
def active_list
|
||||
# nil memoizing
|
||||
return @active_list if @active_list_is_set
|
||||
@active_list ||= self.class.database.view(List.active_by_table_id_view(key: id, include_docs: true, reduce: false, limit: 1)).try(:first)
|
||||
return @active_list if @active_list || @active_list_is_set
|
||||
self.active_list = self.class.database.view(List.active_by_table_id_view(key: id, include_docs: true, reduce: false, limit: 1)).try(:first)
|
||||
end
|
||||
|
||||
def active_list=(val)
|
||||
|
||||
Reference in New Issue
Block a user