diff options
| author | Xinhui | 2016-09-28 17:37:56 +0200 |
|---|---|---|
| committer | Xinhui | 2016-09-28 17:37:56 +0200 |
| commit | 1d84e1ded90688fee6ad80bb4f53c861552e3b68 (patch) | |
| tree | 4fd1102f114a5edaaaaef892733078b3f494194e /app/models/line_referential_sync.rb | |
| parent | 4dbfc621e34d90438095139e72e841a584b44ff7 (diff) | |
| download | chouette-core-1d84e1ded90688fee6ad80bb4f53c861552e3b68.tar.bz2 | |
Templating line_referential_sync_message
Refs #1707
Diffstat (limited to 'app/models/line_referential_sync.rb')
| -rw-r--r-- | app/models/line_referential_sync.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/models/line_referential_sync.rb b/app/models/line_referential_sync.rb index 996266b2e..187e69967 100644 --- a/app/models/line_referential_sync.rb +++ b/app/models/line_referential_sync.rb @@ -1,7 +1,7 @@ class LineReferentialSync < ActiveRecord::Base include AASM belongs_to :line_referential - has_many :line_referential_sync_messages, :dependent => :destroy + has_many :line_referential_sync_messages, -> { order(created_at: :desc) }, :dependent => :destroy after_commit :perform_sync, :on => :create validate :multiple_process_validation, :on => :create @@ -37,27 +37,27 @@ class LineReferentialSync < ActiveRecord::Base end end - def create_sync_message criticity, key, attributes + def create_sync_message criticity, key, message_attributs = {} params = { criticity: criticity, message_key: key, - message_attributs: attributes + message_attributs: message_attributs } line_referential_sync_messages.create params end def log_pending update_attribute(:started_at, Time.now) - create_sync_message :info, :pending, self.attributes + create_sync_message :info, :pending end - def log_successful + def log_successful message_attributs update_attribute(:ended_at, Time.now) - create_sync_message :info, :successful, self.attributes + create_sync_message :info, :successful, message_attributs end - def log_failed error + def log_failed message_attributs update_attribute(:ended_at, Time.now) - create_sync_message :error, :failed, self.attributes.merge(error: error.message) + create_sync_message :error, :failed, message_attributs end end |
