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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:20:44+00:00 2026-05-11T11:20:44+00:00

I’m designing a minimalistic wiki in RoR. Basically a project have many pages. My

  • 0

I’m designing a minimalistic wiki in RoR. Basically a project have many pages. My routing file looks like this:

map.root :controller => 'projects' map.resources :projects, :has_many => :pages map.connect ':id', :controller => 'projects', :action => 'show' map.connect ':project_id/:id', :controller => 'pages', :action => 'show' map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' 

This allow me to access, for example, the ‘main’ page of ‘teaching’ project like this:

http://localhost:3000/teaching/main 

However, as soon as I click a link, it gets transformed to this:

http://localhost:3000/projects/teaching/pages/main 

How can I make the helper methods that create URLs to stick to the scheme I want? I tried named routes, but I must be missing something out because it didn’t worked…

  • 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. 2026-05-11T11:20:45+00:00Added an answer on May 11, 2026 at 11:20 am

    Rails is all about convention over configuration. You have to buy into the conventions if you want the convenience that Rails brings. I would strongly encourage sticking to the RESTful model and accept what rails is doing now.

    With that said, you can probably hack something together. It won’t be pretty and it’ll be a pain every time you want to create a link.

    So first get rid of

     map.resources :projects, :has_many => :pages  map.connect ':controller/:action/:id'  map.connect ':controller/:action/:id.:format' 

    because the map.resources is thing that is sending you to url you don’t want and the two map.connect‘s don’t help you either. So now you should just have

     map.connect ':project_id/:id', :controller => 'pages', :action => 'show'  map.connect ':id', :controller => 'projects', :action => 'show' 

    Then when ever you want to create a link you are going to have to make it yourself. You are going to want to use something like this:

     <%= link_to 'Blah', :project_id => @project, :id => @project.pages.first %> 

    or something like that. I don’t know if that is exactly how are going to specify the route, you are probably going to have to change the :project_id and :id symbols.

    Like I said you don’t want to take this route if you don’t have to. Stick to the conventions as much as you can because it’ll make your life much easier.

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

Sidebar

Related Questions

No related questions found

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.