blob: 30692e625e6e7dc77b6623b5c606a3a81e88e07f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
class Workbench < ActiveRecord::Base
belongs_to :organisation
belongs_to :line_referential
belongs_to :stop_area_referential
has_many :lines, -> (workbench) { Stif::MyWorkbenchScopes.new(workbench).line_scope(self) }, through: :line_referential
has_many :networks, through: :line_referential
has_many :companies, through: :line_referential
has_many :group_of_lines, through: :line_referential
has_many :stop_areas, through: :stop_area_referential
has_many :imports
has_many :workbench_imports
validates :name, presence: true
validates :organisation, presence: true
has_many :referentials
has_many :referential_metadatas, through: :referentials, source: :metadatas
def all_referentials
if line_ids.empty?
Referential.none
else
Referential.joins(:metadatas).where(['referential_metadata.line_ids && ARRAY[?]::bigint[]', line_ids]).ready
end
end
end
|