aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorRobert Dober2017-09-27 13:55:09 +0200
committerGitHub2017-09-27 13:55:09 +0200
commit103e77e1fd28bf6f5ba3ad4f64a0681f2e9dd76f (patch)
tree1735f2f103fe0f8fcc5fa6b66a292912c6036041 /app
parent28a42fb19174eafee38fe3c5f8fa58f89991f44a (diff)
parentd1bd434d78972d4f4156f3e3e864e075cad9e62d (diff)
downloadchouette-core-103e77e1fd28bf6f5ba3ad4f64a0681f2e9dd76f.tar.bz2
Merge pull request #78 from af83/3520-workbench--add-output-association-to-ReferentialSuite
3520 workbench add output association to referential suite
Diffstat (limited to 'app')
-rw-r--r--app/models/workbench.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/workbench.rb b/app/models/workbench.rb
index 30692e625..fe4e6cce1 100644
--- a/app/models/workbench.rb
+++ b/app/models/workbench.rb
@@ -2,6 +2,7 @@ class Workbench < ActiveRecord::Base
belongs_to :organisation
belongs_to :line_referential
belongs_to :stop_area_referential
+ belongs_to :output, class_name: 'ReferentialSuite'
has_many :lines, -> (workbench) { Stif::MyWorkbenchScopes.new(workbench).line_scope(self) }, through: :line_referential
has_many :networks, through: :line_referential
@@ -13,10 +14,13 @@ class Workbench < ActiveRecord::Base
validates :name, presence: true
validates :organisation, presence: true
+ validates :output, presence: true
has_many :referentials
has_many :referential_metadatas, through: :referentials, source: :metadatas
+ before_validation :initialize_output
+
def all_referentials
if line_ids.empty?
@@ -26,4 +30,12 @@ class Workbench < ActiveRecord::Base
end
end
+ private
+
+ def initialize_output
+ # Don't reset `output` if it's already initialised
+ return if !output.nil?
+
+ self.output = ReferentialSuite.create
+ end
end