mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-01 04:32:16 +08:00
Remove result validation [SCI-2376]
This commit is contained in:
parent
29fe58de80
commit
e10ed86fa1
1 changed files with 0 additions and 18 deletions
|
@ -4,7 +4,6 @@ class Result < ApplicationRecord
|
|||
auto_strip_attributes :name, nullify: false
|
||||
validates :user, :my_module, presence: true
|
||||
validates :name, length: { maximum: Constants::NAME_MAX_LENGTH }
|
||||
validate :text_or_asset_or_table
|
||||
|
||||
belongs_to :user, inverse_of: :results, optional: true
|
||||
belongs_to :last_modified_by,
|
||||
|
@ -104,21 +103,4 @@ class Result < ApplicationRecord
|
|||
true
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def text_or_asset_or_table
|
||||
num_of_assigns = 0
|
||||
num_of_assigns += result_text.blank? ? 0 : 1
|
||||
num_of_assigns += asset.blank? ? 0 : 1
|
||||
num_of_assigns += table.blank? ? 0 : 1
|
||||
|
||||
# Theoretically, we should make sure == 1, not > 1,
|
||||
# but due to GUI problems this is how it is
|
||||
if num_of_assigns > 1
|
||||
errors.add(:base, "Result can only be instance of text/asset/table.")
|
||||
elsif num_of_assigns < 1
|
||||
errors.add(:base, "Result should be instance of text/asset/table.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue