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

  • SEARCH
  • Home
  • 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 6742355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:50:01+00:00 2026-05-26T11:50:01+00:00

I have a CMS style application where the user can set a custom url

  • 0

I have a CMS style application where the user can set a custom url and it routes to our “content_pages” controller.

To support this we have 3 wildcard routes defined.

I’m trying to constrain these wildcards so that they only respond to requests where the format is html, json, or xml and nothing else. This stems out of a problem where a missing favicon.ico results in a series of queries and web requests because it routes to the content_pages controller and then 404s.

Here’s what I have so far but the constraint simply doesn’t work. (favicon still routes)

get "/:id/edit", to: "content_pages#edit", :constraints => {:id => /.*/, :format => "[html|xml|json]"}, as: :edit_content_page                                                                                                          
put "/:id", to: "content_pages#update", :constraints => {:id => /.*/, :format => "[html|xml|json]"}, as: :content_page
get "/:id", to: "content_pages#show", :constraints => {:id => /.*/, :format => "[html|xml|json]"}, as: :content_page

I also tried putting this into a custom constraint class but then the actions on content_pages that arent included here (like /content_pages which routes to index) don’t render.

Here’s the earlier resource statement that wires up the other actions.

resources :content_pages, except: [:get, :edit, :update] do 
  collection do 
    get :get_url 
  end 
end

Any thoughts on how i can make this constraint apply without breaking our other, non-constrained actions?

  • 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-26T11:50:01+00:00Added an answer on May 26, 2026 at 11:50 am

    If the only file type you want to exclude is .ico, then you could update your :id constraint to explicitly exclude it:

    get "/:id", to: "content_pages#show", :constraints => {:id => /.+?(?<!ico)/, :format => /(html|xml|json)/}, as: :content_page
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that I would like to embed inside our companies CMS.
I have this piece of code in my cms: <ul class=subsection_tabs id=tab_group_one style=clear:none;> <?php
I have a cms which stores comments against articles. These comments can be both
We have a CMS where people can upload images. We currently don't offer a
This is a bit of a specific request unfortunately. I have a CMS that
I have written a CMS for a website. You can create pages and do
For our CMS we have a site manager that defines the site's tree structure
So i have a custom CMS running under .Net 3.5 written entirely in c#.
I have created a custom, specialized CMS with a number of clients on it,
The Scenario I am building a custom CMS for a communications application. The users

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.