diff options
| author | Luc Donnet | 2017-09-07 16:28:32 +0200 |
|---|---|---|
| committer | Luc Donnet | 2017-09-07 16:28:32 +0200 |
| commit | 99aff9c3e63fb15b555806847bc14fbf56eeef2a (patch) | |
| tree | 339ca9b884504c19cecc0956c629614ace926901 /app/models | |
| parent | 8b5a3e68c37a9331f47608faaa6903a01c390861 (diff) | |
| parent | 01b0d19c329810a083153efbf040911e4079f6ef (diff) | |
| download | chouette-core-99aff9c3e63fb15b555806847bc14fbf56eeef2a.tar.bz2 | |
Merge branch 'master' of github.com:AF83/stif-boiv
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/chouette/active_record.rb | 13 | ||||
| -rw-r--r-- | app/models/referential.rb | 6 |
2 files changed, 12 insertions, 7 deletions
diff --git a/app/models/chouette/active_record.rb b/app/models/chouette/active_record.rb index 1862319af..e12f30266 100644 --- a/app/models/chouette/active_record.rb +++ b/app/models/chouette/active_record.rb @@ -2,10 +2,8 @@ require 'deep_cloneable' module Chouette class ActiveRecord < ::ActiveRecord::Base - self.abstract_class = true - - before_save :nil_if_blank + before_save :nil_if_blank, :set_data_source_ref # to be overridden to set nullable attrs when empty def self.nullable_attributes @@ -16,17 +14,22 @@ module Chouette self.class.nullable_attributes.each { |attr| self[attr] = nil if self[attr].blank? } end - def human_attribute_name(*args) self.class.human_attribute_name(*args) end + def set_data_source_ref + if self.respond_to?(:data_source_ref) + self.data_source_ref ||= 'DATASOURCEREF_EDITION_BOIV' + end + end + # TODO: Can we remove this? # class << self # alias_method :create_reflection_without_chouette_naming, :create_reflection # def create_reflection(macro, name, options, active_record) - # options = + # options = # Reflection.new(macro, name, options, active_record).options_with_default # create_reflection_without_chouette_naming(macro, name, options, active_record) diff --git a/app/models/referential.rb b/app/models/referential.rb index ecfc69c4a..65e203f9f 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -1,3 +1,4 @@ +# coding: utf-8 class Referential < ActiveRecord::Base include DataFormatEnumerations @@ -185,7 +186,6 @@ class Referential < ActiveRecord::Base before_validation :assign_slug, :on => :create before_validation :assign_prefix, :on => :create before_create :create_schema - after_create :clone_schema, if: :created_from before_destroy :destroy_schema @@ -289,7 +289,9 @@ class Referential < ActiveRecord::Base end def create_schema - Apartment::Tenant.create slug + unless created_from + Apartment::Tenant.create slug + end end def assign_slug |
