2017-05-16 21:27:36 +08:00
|
|
|
class RepositoryRow < ActiveRecord::Base
|
|
|
|
belongs_to :repository
|
|
|
|
belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User'
|
2017-06-06 23:35:29 +08:00
|
|
|
belongs_to :last_modified_by, foreign_key: :last_modified_by_id,
|
|
|
|
class_name: 'User'
|
2017-05-16 21:27:36 +08:00
|
|
|
has_many :repository_cells, dependent: :destroy
|
|
|
|
has_many :repository_columns, through: :repository_cells
|
2017-06-07 19:36:39 +08:00
|
|
|
has_many :my_module_repository_rows,
|
2017-06-06 23:35:29 +08:00
|
|
|
inverse_of: :repository_row, dependent: :destroy
|
2017-06-07 19:36:39 +08:00
|
|
|
has_many :my_modules, through: :my_module_repository_rows
|
2017-05-16 21:27:36 +08:00
|
|
|
|
|
|
|
auto_strip_attributes :name, nullify: false
|
|
|
|
validates :name,
|
|
|
|
presence: true,
|
|
|
|
length: { maximum: Constants::NAME_MAX_LENGTH }
|
|
|
|
validates :created_by, presence: true
|
|
|
|
end
|