mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-29 11:45:18 +08:00
17 lines
727 B
Ruby
17 lines
727 B
Ruby
class CustomField < ActiveRecord::Base
|
|
auto_strip_attributes :name, nullify: false
|
|
validates :name,
|
|
presence: true,
|
|
length: { maximum: NAME_MAX_LENGTH },
|
|
uniqueness: { scope: :organization, case_sensitive: true },
|
|
exclusion: { in: ['Assigned', 'Sample name', 'Sample type',
|
|
'Sample group', 'Added on', 'Added by'] }
|
|
validates :user, :organization, presence: true
|
|
|
|
belongs_to :user, inverse_of: :custom_fields
|
|
belongs_to :organization, inverse_of: :custom_fields
|
|
belongs_to :last_modified_by,
|
|
foreign_key: 'last_modified_by_id',
|
|
class_name: 'User'
|
|
has_many :sample_custom_fields, inverse_of: :custom_field
|
|
end
|