Group entity. Group has many projects
This commit is contained in:
parent
2e1c3c52bc
commit
fa3ae24ca7
8 changed files with 116 additions and 1 deletions
22
app/models/group.rb
Normal file
22
app/models/group.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: groups
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255) not null
|
||||
# code :string(255) not null
|
||||
# owner_id :integer not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class Group < ActiveRecord::Base
|
||||
attr_accessible :code, :name, :owner_id
|
||||
|
||||
has_many :projects
|
||||
belongs_to :owner, class_name: "User"
|
||||
|
||||
validates :name, presence: true, uniqueness: true
|
||||
validates :code, presence: true, uniqueness: true
|
||||
validates :owner_id, presence: true
|
||||
end
|
|
@ -11,6 +11,7 @@ class Project < ActiveRecord::Base
|
|||
attr_accessor :error_code
|
||||
|
||||
# Relations
|
||||
belongs_to :group
|
||||
belongs_to :owner, class_name: "User"
|
||||
has_many :users, through: :users_projects
|
||||
has_many :events, dependent: :destroy
|
||||
|
@ -173,4 +174,6 @@ end
|
|||
# wall_enabled :boolean default(TRUE), not null
|
||||
# merge_requests_enabled :boolean default(TRUE), not null
|
||||
# wiki_enabled :boolean default(TRUE), not null
|
||||
# group_id :integer
|
||||
#
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue