scinote-web/app/models/repository.rb
Oleksii Kriuchykhin ad8dd6d740 PR fixes [SCI-1274]
2017-06-07 15:23:25 +02:00

16 lines
580 B
Ruby

class Repository < ActiveRecord::Base
belongs_to :team
belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User'
has_many :repository_columns
has_many :repository_rows
has_many :repository_table_states,
inverse_of: :repository, dependent: :destroy
auto_strip_attributes :name, nullify: false
validates :name,
presence: true,
uniqueness: { scope: :team, case_sensitive: false },
length: { maximum: Constants::NAME_MAX_LENGTH }
validates :team, presence: true
validates :created_by, presence: true
end