diff options
| author | Xinhui | 2017-09-07 14:29:15 +0200 | 
|---|---|---|
| committer | Xinhui | 2017-09-07 14:29:15 +0200 | 
| commit | 1ec6f453f34e2475cc5a022d516e484131461025 (patch) | |
| tree | 80a600acdd0cb62958b9496ceeb5d66c9dbdd5b3 /app/models/chouette | |
| parent | 7b7671a9dc96f6af652f11bff2d067afcf9a6ace (diff) | |
| download | chouette-core-1ec6f453f34e2475cc5a022d516e484131461025.tar.bz2 | |
Set default value for data_source_ref
Refs #4406
Diffstat (limited to 'app/models/chouette')
| -rw-r--r-- | app/models/chouette/active_record.rb | 13 | 
1 files changed, 8 insertions, 5 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)  | 
