title: Ruby: What does $1 mean?
body: <p>I'm watching a RailsCast on polymorphic associations.   <a href="http://railscasts.com/episodes/154-polymorphic-association?view=asciicast" rel="noreferrer">http://railscasts.com/episodes/154-polymorphic-association?view=asciicast</a></p>
  
  <p>There's three different models Article, Photo and Event that each take a comment from Comment.rb. (Article, Photo and Event each of a article_id, photo_id, and event_id). In listing the comments he has the problem of figuring out which of the 3 models to list the comments for, so he does this in the index action</p>
  
  <pre><code>def index
    @commentable = find_commentable
    @comments = @commentable.comments
  end
  
  
  def find_commentable
    params.each do |name, value|
      if name =~ /(.+)_id$/
        return $1.classify.constantize.find(value)
      end
    end
    nil
  end
  </code></pre>
  
  <p>My question is, what is <code>$1</code>? </p>