title: How to find the longest string in a column with Ruby on Rails?
body: <p>What is the most efficient way in Ruby to find the <em>longest</em> string from a column <code>X</code>? </p>
  
  <p>Update: </p>
  
  <p>This also sort of works:</p>
  
  <pre><code>def self.length_of_longest_number
    Invoice.order("LENGTH(number) DESC").first.number.length
  end
  </code></pre>
  
  <p>Just curious to know if's efficient or not. And if it works in MySQL <em>and</em> Postgres...</p>