title: request.env["HTTP_USER_AGENT"] in routes.rb
body: <p>I'm trying to serve up different pages based on whether a user is a bot or not, so I placed this code in the routes.rb file:</p>
  
  <pre><code>request.env["HTTP_USER_AGENT"].include? "bot"
  </code></pre>
  
  <p>And get this error:</p>
  
  <pre><code>block in &lt;top (required)&gt;': undefined local variable or method `request' for #&lt;ActionDispatch::Routing::Mapper:0x007fe30f329f98&gt; (NameError)
  </code></pre>
  
  <p>Any ideas how I can make this work?</p>
  
  <p>Been looking around and found this, but it still gives me an error:</p>
  
  <pre><code>constraints :user_agent =&gt; /bot/ do
      root :to =&gt; "events#index"
    end
    constraints :user_agent =&gt; /^((?!bot).)*$/ do
      root :to =&gt; "main#index"
    end
  </code></pre>