title: How to sort movies alphabetically in Rails?
body: <p>If you visit <a href="http://ccvideofinder.heroku.com/" rel="noreferrer">http://ccvideofinder.heroku.com/</a>, it's a good example of what I'm referring to. </p>
  
  <p>How can this be done in Rails? I was thinking maybe using <code>case</code>/<code>when</code> statements but after fooling around with IRB for some time I couldn't figure it out.</p>
  
  <hr>
  
  <p>In the model:</p>
  
  <pre><code>class Movies &lt; ActiveRecord::Base
    validates_presence_of :title
  
    def self.find_by_first_letter(letter)
      find(:all, :conditions =&gt; ['title LIKE ?', "#{letter}%"], :order =&gt; 'title ASC')
    end
  
  end
  </code></pre>
  
  <p>In the controller:</p>
  
  <pre><code>@result = Movie.find_by_first_letter(params[:letter])
  </code></pre>