Added IssueComments + ForeignKeys + Indexes
This commit is contained in:
parent
d49922eb63
commit
683722ed5c
16 changed files with 285 additions and 18 deletions
|
@ -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 )
|
||||
|
|
6
app/models/issue_comment.rb
Normal file
6
app/models/issue_comment.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class IssueComment < ActiveRecord::Base
|
||||
belongs_to :issue
|
||||
belongs_to :user
|
||||
|
||||
validates :body, :presence => true
|
||||
end
|
|
@ -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)) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue