- 1
 - 2
 - 3
 - 4
 
scope :search_by_title, proc { |title|
  title = sanitize_sql(title).gsub(/'/, '').strip().split().join(':* &') << ":*"
  where("to_tsvector('english', title) @@ to_tsquery('english', '#{title}')").order("case when title ~* '^#{title}' then 1 else 2 end")
}
                                    
 Follow us!