title: Rails slugs in URL - using Active Record Model Post's Title attribute instead of ID
body: <p>I've been trying to make my Rails create URLs to show records by using their title instead of their ID in URL such as:</p>
  
  <p>/posts/a-post-about-rockets</p>
  
  <p>Following a tutorial online I did the following:</p>
  
  <hr>
  
  <p>Because the ID is no longer in the URL, we have to change the code a bit.</p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
    before_create :create_slug
  
    def to_param
      slug
    end
  
    def create_slug
      self.slug = self.title.parameterize
    end
  end
  </code></pre>
  
  <p>When a post is created, the URL friendly version of the title is stored in the database, in the slug column. </p>
  
  <p>We also have to update the finds to find records using the slug column instead of using the ID.</p>
  
  <pre><code>class ProjectsController &lt; ApplicationController
    def show
      @project = Project.find_by_slug!(params[:id])
    end
  end
  </code></pre>
  
  <hr>
  
  <p>At this point it seems to work except showing a record, because find_by_slug! doesnt exist yet. </p>
  
  <p>I'm an extreme newb - where should I be defining it?</p>