Fix includes on api queries

This commit is contained in:
Paul Chavard 2018-11-08 14:36:53 +01:00
parent 80189def98
commit 6706b9004f
3 changed files with 5 additions and 3 deletions

View file

@ -5,6 +5,11 @@ class Champ < ApplicationRecord
has_one_attached :piece_justificative_file
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
scope :updated_since?, -> (date) { where('champs.updated_at > ?', date) }

View file

@ -1,6 +1,4 @@
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
# the following collections on unsaved records.
def cadastres

View file

@ -37,7 +37,6 @@ class Champs::SiretChamp < Champ
]
]
belongs_to :etablissement, dependent: :destroy
accepts_nested_attributes_for :etablissement, allow_destroy: true, update_only: true
def search_terms