diff options
| author | Teddy Wing | 2017-09-22 18:58:54 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-09-22 18:58:54 +0200 |
| commit | beced2b5817da0082aa9f3af76581a524535d801 (patch) | |
| tree | d8ccbd6db3e3cf6a3173b4e34e111e8a9f7af9ac /app/models | |
| parent | 16f01969fedd429b2c7916eafb19a8a9263bce81 (diff) | |
| download | chouette-core-beced2b5817da0082aa9f3af76581a524535d801.tar.bz2 | |
Add `has_many` association between `Referential` and `ReferentialSuite`
`ReferentialSuite` has many `Referential`s. Need to add a foreign key
column to the `referentials` table to allow that to work.
Refs #3519
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/referential.rb | 2 | ||||
| -rw-r--r-- | app/models/referential_suite.rb | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/app/models/referential.rb b/app/models/referential.rb index af08aa868..c7b52ddf8 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -45,6 +45,8 @@ class Referential < ActiveRecord::Base has_many :stop_areas, through: :stop_area_referential belongs_to :workbench + belongs_to :referential_suite + scope :ready, -> { where(ready: true) } scope :in_periode, ->(periode) { where(id: referential_ids_in_periode(periode)) } scope :include_metadatas_lines, ->(line_ids) { where('referential_metadata.line_ids && ARRAY[?]::bigint[]', line_ids) } diff --git a/app/models/referential_suite.rb b/app/models/referential_suite.rb index c2f40913e..9fd25ef3f 100644 --- a/app/models/referential_suite.rb +++ b/app/models/referential_suite.rb @@ -1,4 +1,6 @@ class ReferentialSuite < ActiveRecord::Base belongs_to :new, class_name: 'Referential' belongs_to :current, class_name: 'Referential' + + has_many :referentials end |
