Merge pull request #730 from Ducz0r/lm-sci-1427-fix

Fixes DEPRECATION WARNING-s for Rails 5.1.2 [SCI-1427]
This commit is contained in:
Luka Murn 2017-07-05 09:21:35 +02:00 committed by GitHub
commit 738fc46080
5 changed files with 8 additions and 7 deletions

View file

@ -8,7 +8,7 @@ class AssetTextDatum < ApplicationRecord
after_save :update_ts_index after_save :update_ts_index
def update_ts_index def update_ts_index
if data_changed? if saved_change_to_data?
sql = "UPDATE asset_text_data " + sql = "UPDATE asset_text_data " +
"SET data_vector = to_tsvector(data) " + "SET data_vector = to_tsvector(data) " +
"WHERE id = " + Integer(id).to_s "WHERE id = " + Integer(id).to_s

View file

@ -12,7 +12,8 @@ class MyModule < ApplicationRecord
validates :description, length: { maximum: Constants::TEXT_MAX_LENGTH } validates :description, length: { maximum: Constants::TEXT_MAX_LENGTH }
validates :x, :y, :workflow_order, presence: true validates :x, :y, :workflow_order, presence: true
validates :experiment, presence: true validates :experiment, presence: true
validates :my_module_group, presence: true, if: "!my_module_group_id.nil?" validates :my_module_group, presence: true,
if: proc { |mm| !mm.my_module_group_id.nil? }
belongs_to :created_by, belongs_to :created_by,
foreign_key: 'created_by_id', foreign_key: 'created_by_id',

View file

@ -669,9 +669,9 @@ class Protocol < ApplicationRecord
def update_linked_children def update_linked_children
# Increment/decrement the parent's nr of linked children # Increment/decrement the parent's nr of linked children
if self.parent_id_changed? if saved_change_to_parent_id?
if self.parent_id_was != nil unless parent_id_before_last_save.nil?
p = Protocol.find_by_id(self.parent_id_was) p = Protocol.find_by_id(parent_id_before_last_save)
p.record_timestamps = false p.record_timestamps = false
p.decrement!(:nr_of_linked_children) p.decrement!(:nr_of_linked_children)
end end

View file

@ -9,7 +9,7 @@ class Step < ApplicationRecord
validates :position, presence: true validates :position, presence: true
validates :completed, inclusion: { in: [true, false] } validates :completed, inclusion: { in: [true, false] }
validates :user, :protocol, presence: true validates :user, :protocol, presence: true
validates :completed_on, presence: true, if: "completed?" validates :completed_on, presence: true, if: proc { |s| s.completed? }
belongs_to :user, inverse_of: :steps, optional: true belongs_to :user, inverse_of: :steps, optional: true
belongs_to :last_modified_by, belongs_to :last_modified_by,

View file

@ -120,7 +120,7 @@ class Table < ApplicationRecord
end end
def update_ts_index def update_ts_index
if contents_changed? if saved_change_to_contents?
sql = "UPDATE tables " + sql = "UPDATE tables " +
"SET data_vector = " + "SET data_vector = " +
"to_tsvector(substring(encode(contents::bytea, 'escape'), 9)) " + "to_tsvector(substring(encode(contents::bytea, 'escape'), 9)) " +