mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-23 04:02:19 -05:00
22 lines
505 B
Ruby
22 lines
505 B
Ruby
class Problem < ApplicationRecord
|
|
belongs_to :problematic, polymorphic: true
|
|
|
|
validates :category, uniqueness: {scope: :problematic}, presence: true
|
|
|
|
enum :category, [
|
|
:missing,
|
|
:empty,
|
|
:destination_exists, # No longer used, but kept for compatibility
|
|
:nesting
|
|
]
|
|
|
|
def self.create_or_clear(problematic, cat, present)
|
|
if present
|
|
problematic.problems.create(category: cat)
|
|
else
|
|
problematic.problems.where(category: cat).destroy_all
|
|
end
|
|
present
|
|
end
|
|
end
|