@@ -35,17 +35,17 @@ class SupportTicket < ApplicationRecord
3535 validates :subject , presence : true , length : { minimum : 5 , maximum : 200 }
3636 validates :description , presence : true , length : { minimum : 10 }
3737 validates :category , presence : true , inclusion : {
38- in : %w[ technical feature_request billing riot_integration other ]
38+ in : %w[ technical feature_request billing riot_integration getting_started other ]
3939 }
4040 validates :priority , presence : true , inclusion : {
4141 in : %w[ low medium high urgent ]
4242 }
4343 validates :status , presence : true , inclusion : {
44- in : %w[ open in_progress waiting_client resolved closed ]
44+ in : %w[ open in_progress waiting_user resolved closed ]
4545 }
4646
4747 # Scopes
48- scope :open_tickets , -> { where ( status : %w[ open in_progress waiting_client ] ) }
48+ scope :open_tickets , -> { where ( status : %w[ open in_progress waiting_user ] ) }
4949 scope :closed_tickets , -> { where ( status : %w[ resolved closed ] ) }
5050 scope :unassigned , -> { where ( assigned_to_id : nil ) }
5151 scope :assigned , -> { where . not ( assigned_to_id : nil ) }
@@ -60,7 +60,8 @@ class SupportTicket < ApplicationRecord
6060
6161 # Instance methods
6262 def ticket_number
63- "TICKET-#{ id &.split ( '-' ) &.first &.upcase || 'DRAFT' } "
63+ prefix = id ? id . split ( '-' ) . first . upcase : 'DRAFT'
64+ "TICKET-#{ prefix } "
6465 end
6566
6667 def assign_to! ( user )
@@ -131,8 +132,9 @@ def track_status_changes
131132 end
132133
133134 def create_system_message ( content )
135+ system_actor = assigned_to || user
134136 messages . create! (
135- user : User . system_user , # You'll need to create a system user
137+ user : system_actor ,
136138 content : content ,
137139 message_type : 'system'
138140 )
0 commit comments