diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index ec7698a0a..10621a59f 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -478,7 +478,11 @@ class TicketsController < ApplicationController end # do query - tickets_all = Ticket.where(conditions).where( '( title LIKE ? OR number LIKE ? )', "%#{query}%", "%#{query}%" ).limit(limit).order(:created_at) + tickets_all = Ticket.where(conditions). + where( '( title LIKE ? OR number LIKE ? OR ticket_articles.body LIKE ? OR ticket_articles.from LIKE ? OR ticket_articles.to LIKE ? OR ticket_articles.subject LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" ). + joins(:ticket_articles). + limit(limit). + order(:created_at) # build result list tickets = [] diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 8de2fdbd5..72856d570 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -4,7 +4,7 @@ class Ticket < ApplicationModel before_destroy :destroy_dependencies belongs_to :group - has_many :articles, :after_add => :cache_update, :after_remove => :cache_update + has_many :ticket_articles, :class_name => 'Ticket::Article', :after_add => :cache_update, :after_remove => :cache_update belongs_to :organization belongs_to :ticket_state, :class_name => 'Ticket::State' belongs_to :ticket_priority, :class_name => 'Ticket::Priority'