Fix includes on api queries
This commit is contained in:
parent
80189def98
commit
6706b9004f
3 changed files with 5 additions and 3 deletions
|
@ -5,6 +5,11 @@ class Champ < ApplicationRecord
|
||||||
has_one_attached :piece_justificative_file
|
has_one_attached :piece_justificative_file
|
||||||
has_one :virus_scan
|
has_one :virus_scan
|
||||||
|
|
||||||
|
# We declare champ specific relationships (Champs::CarteChamp and Champs::SiretChamp)
|
||||||
|
# here because otherwise we can't easily use includes in our queries.
|
||||||
|
has_many :geo_areas, dependent: :destroy
|
||||||
|
belongs_to :etablissement, dependent: :destroy
|
||||||
|
|
||||||
delegate :libelle, :type_champ, :order_place, :mandatory?, :description, :drop_down_list, to: :type_de_champ
|
delegate :libelle, :type_champ, :order_place, :mandatory?, :description, :drop_down_list, to: :type_de_champ
|
||||||
|
|
||||||
scope :updated_since?, -> (date) { where('champs.updated_at > ?', date) }
|
scope :updated_since?, -> (date) { where('champs.updated_at > ?', date) }
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
class Champs::CarteChamp < Champ
|
class Champs::CarteChamp < Champ
|
||||||
has_many :geo_areas, foreign_key: :champ_id, dependent: :destroy
|
|
||||||
|
|
||||||
# We are not using scopes here as we want to access
|
# We are not using scopes here as we want to access
|
||||||
# the following collections on unsaved records.
|
# the following collections on unsaved records.
|
||||||
def cadastres
|
def cadastres
|
||||||
|
|
|
@ -37,7 +37,6 @@ class Champs::SiretChamp < Champ
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
belongs_to :etablissement, dependent: :destroy
|
|
||||||
accepts_nested_attributes_for :etablissement, allow_destroy: true, update_only: true
|
accepts_nested_attributes_for :etablissement, allow_destroy: true, update_only: true
|
||||||
|
|
||||||
def search_terms
|
def search_terms
|
||||||
|
|
Loading…
Add table
Reference in a new issue