title: Rails 4: how to make exceptions to wildcard routes so I an access mail previews?
body: <p>In <code>routes.rb</code> I have the following:</p>
  
  <pre><code>get '*category/*location' =&gt; 'landing#show'
  get '*category' =&gt; 'landing#show'
  </code></pre>
  
  <p>This is keeping me from being able to view mail previews at <code>/rails/previews</code> because I get redirected just as if I had typed <code>/painting</code> or <code>/painting/chicago</code>. </p>
  
  <p>Using the Rails routing guides, I tried to make constraints like this:</p>
  
  <pre><code>  get '*category/*location' =&gt; 'landing#show', constraints: { category: /(?!rails)/, location: /(?!mailers)/ }
    get '*category' =&gt; 'landing#show', constraints: { category: /(?!rails\/mailers)/ }
  </code></pre>
  
  <p>...however, this seems to either be blocking everything <em>except</em> <code>/rails/mailers</code> (I can now open the mail previews but all of the previous dynamic behavior is broken) or it's just made the two lines null - not sure which. All I can tell is that I can now access the mail previews but the previously dynamic behavior is broken.</p>
  
  <p>The other idea I had was simply to skip over the wildcard lines if I'm not in development like so:</p>
  
  <pre><code>  unless Rails.env.development?
      get '*category/*location' =&gt; 'landing#show'
      get '*category' =&gt; 'landing#show'
    end
  </code></pre>
  
  <p>However, this seems a bit ham-fisted. It prevents me from viewing the wildcard behavior in development, and I'm just wondering if there's a better way using constraints. Can someone help me figure out what I need to do to get those wildcards to work <em>unless</em> the url ends in <code>/rails/server</code>. </p>