Added IssueComments + ForeignKeys + Indexes

This commit is contained in:
Shrey 2015-05-28 23:51:54 +05:30 committed by Matt Amos
parent d49922eb63
commit 683722ed5c
16 changed files with 285 additions and 18 deletions

View file

@ -1,8 +1,10 @@
class Issue < ActiveRecord::Base
belongs_to :reportable, :polymorphic => true
has_many :reports
has_many :comments, :class_name => "IssueComment"
validates :reportable_id, :uniqueness => { :scope => [ :reportable_type ] }
belongs_to :user
validates :user_id, :presence => true
# Check if more statuses are needed
enum status: %w( open ignored resolved )

View file

@ -0,0 +1,6 @@
class IssueComment < ActiveRecord::Base
belongs_to :issue
belongs_to :user
validates :body, :presence => true
end

View file

@ -27,6 +27,8 @@ class User < ActiveRecord::Base
has_many :roles, :class_name => "UserRole"
has_many :issues
has_many :issue_comments
has_many :reports
scope :visible, -> { where(:status => %w(pending active confirmed)) }