title: Sinatra/Rack params[] in before block
body: <p>I'm making a site using Sinatra, everything is going well, or was until I needed to access the <code>params[]</code> hash in the <code>before</code> block.</p>
  
  <p>Basically, I'm trying to do this:</p>
  
  <pre><code>before do
    if params[:forum_id]
      @forum = Forum.find(params[:forum_id])
      build_breadcrumbs(@forum.parents)
      # ... more code, snipped to keep it short
    end
  end
  </code></pre>
  
  <p>But the thing is, I can't call the <code>params[]</code> hash in the <code>before</code> block, does anyone have any ideas?</p>
  
  <p>The reason I'm putting this code in the <code>before</code> block is because I'd rather not have to go and put it in every one of my <code>get</code> and <code>post</code> blocks for every page.</p>