Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3316310
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:27:16+00:00 2026-05-17T22:27:16+00:00

To clarify, here’s the situation: I’m building a really simple CMS that will become

  • 0

To clarify, here’s the situation:

I’m building a really simple CMS that will become the base for several apps I have plans to create in the future. I’d really like to be able to create a page called “About” (which will be mostly static) and automatically be able to access it at “/about”, without having to modify routes.rb.

I currently have a wildcard route like this, which works just fine:

match '/*slug', :to => 'pages#dynamic_page', 
                :constraints => { :fullpath => /.+\.html/ }

The issue is, I’d really like to be able to omit the “.html” at the end. However, I prefer the extension over a url like “/pages/about”. Is there a better way to handle this? The issue that occurs when I remove the constraint is that requests to items that don’t exist go through the Rails router, which is obviously less than desirable, as that’s extra overhead that has to be handled.

Is there a better way? Is there some way to avoid the router entirely if the page being requested is a static page, so I can eliminate the wildcard route?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:27:17+00:00Added an answer on May 17, 2026 at 10:27 pm

    To solve this in the Rails router, tou should be able to just add a route to the very bottom of routes.rb that looks something like this:

    match '/:slug(.:format)', :to => 'pages#dynamic_page'
    

    The parentheses mark the :format parameter of the route as optional, so /about or /about.html should work.

    This needs to be at the bottom of the routes file, so that it won’t interfere with your other routes.

    If you want to avoid the Rails router, you have two options, both a little more advanced.

    1. In your web server’s config, add a rewrite rule that maps /about to some other URI.

    2. Add a Rack middleware or Rails metal to handle your static page routes. This avoids running these requests through the whole Rails routing stack, but the Rails 3 router is pretty fast and I’m not sure it’s worth it to add this much complexity just to serve a semi-static page.

    You may also wanna look into the High Voltage gem. It’s a Rails engine for serving up mostly static pages. By default it gives you a /pages/about style URL, but you could then add the following to your routes to make it prettier:

    # High Voltage treats pages like a REST resource; the page's name is the ID 
    match '/:id(.:format)', :to => 'high_voltage/pages#show'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here’s the situation: We have a 3rd party application that intermittently displays an error
I just have some codes here to clarify my doubts on linq xml parsing.
I should clarify that I am looking for a client-side solution. Alternatively, is there
Can anyone clarify/elucidate the situation with respect to -[NSNotificationCenter addObserver:selector:name:object:] ? What types of
Is there a practical algorithm that gives multiplication chains To clarify, the goal is
Here's what I'm thinking: class Widget < ActiveRecord::Base has_one :widget_layout end class WidgetLayout <
Before anything, let me first clarify that the below thoughts are purely my personal
I have got a question on regular expression. Though simple, I got some contracting
I'm just hoping to clarify the whole facebook UID issue, here . It talks
Here's an interesting question ... is there a collection that is a struct somewhere

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.