class Question < ActiveRecord::Base
  belongs_to :user
  has_many :answers

  validates_presence_of :body
  validates_presence_of :title
end
class Question < ActiveRecord::Base
  belongs_to :user
  has_many :answers

  validates_presence_of :body
  validates_presence_of :title

  def self.search(words)
    matches = []
    words.split(' ').each do |word|
      matches << Question.all.map { |q| q.title.include?(word) || q.body.include?(word) }
    end
    matches
  end
end
Add search class method for Question.
Add search class method for Question.
