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 4244104
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:39:52+00:00 2026-05-21T03:39:52+00:00

I am thinking about having different site sections of a Rails 3 webapp. The

  • 0

I am thinking about having different site sections of a Rails 3 webapp. The site sections should show the same resources using the same controller and the same views.

So http://foo.org/premium/products/1 should present the same product as http://foo.org/products/1 (maybe with some modifications dependent on the section).

For handling that I thought about rewriting the URL somehow (maybe in routes.rb, at the Rack level or the server level), so that http://foo.org/premium/products/1 becomes http://foo.org/products/1?section=premium. Are there any better solutions for that?

But the real problem I see is when generating the links of those sites as those should retain the section. E.g. a link on the site http://foo.org/premium/products/1 to the product with id 2 should be http://foo.org/premium/products/2 and not http://foo.org/products/2?section=premium.

Unfortunately this is not so trivial as link_to and *_path don’t know about the sections. I also want to make this highly dynamic so that I can easily add and remove sections without touching static routes.

I thought about rewriting the URLs after they were generated by link_to. Would this be a good approach? Any other suggestions?

  • 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-21T03:39:53+00:00Added an answer on May 21, 2026 at 3:39 am

    Finally I chose the approach of rewriting the URLs as there are only minor changes between those site sections (e.g. another background). That way I could reuse all MVC classes instead of creating new stuff when using for example routing namespaces.

    For rewriting the URLs I use Rack middlewares. All incoming URLs are rewritten by rack-rewrite. Links of the response body are rewritten by another custom middleware (something like done in this Railscasts transcript.

    So URLs like /premium/products/1 will end up as /products/1?section=premium (and vice versa).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was thinking about using openid for my international site. So I was reading
We are currently thinking about different ways to implement custom fields for our web
Thinking about avoiding code replication, I got a question that catches me every time
Thinking about if we modify the definition of Hamiltonian path as we need to
Im thinking about to use a DB for my logs instead of a normal
Im thinking about building an application on our website to track order places through
Been thinking about this for hours now. Im building a simple slideshow application, where
Just thinking about the best way to build an Order form that would (from
Im thinking about learn to develop app for iOS. I had a lot of
I'm thinking about writing a FLAC to ALAC and/or FLAC to AAC converter, probably

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.