Last Updated: February 25, 2016
·
541
· gwinn

Search email message by title

Simple snippet.

thread = Email.where(["email = ? AND subject LIKE ?", email, "%#{subject.gsub(/(Re:\s)+?|(Fwd:\s)+?|Re\[\d+\]:\s/i, "")}%"]).last(10)

P.S. Yes. We store messages in database :)