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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:12:06+00:00 2026-05-17T15:12:06+00:00

I am a relative beginner at Rails 3 routing and it has now caused

  • 0

I am a relative beginner at Rails 3 routing and it has now caused me enough pain that I want to figure out the real solution.

A couple of details:

  • I have some semi-restful controllers that contain some methods outside the standard seven new, create, edit, update, destroy, etc.

  • Generally, I want my routes page to map everything to ‘controller/action’, but perhaps with the rare exception.

  • I am under the impression that having a general mapping like match ‘:controller/:action’ is not recommended for security reasons, even though I prefer to use session data rather than params which are more easily modified.

What’s the best way to go about structuring my routes document in an efficient way?

  • 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-17T15:12:07+00:00Added an answer on May 17, 2026 at 3:12 pm

    you can use this match in routes.rb:

      match ':controller(/:action(/:id(.:format)))'
    

    or some of its variant like get instead of match, etc.

    As routes are resolved from top to bottom then you can use your exceptions (and standard resource routes) above the generic route rule.

    As for the security concerns – if you have this generic rule in your routing table then you should protected all non-action methods in controller with private keyword.

    There is another problem with generic rule. Compare this rule:

    get "foo/show/:id", :to => "foo#show"
    

    with the generic one. The good thing of this explicit rule is the fact that it’s never called for /foo/show (without the id part) so you will not be in situation when there is no params[:id] in your action method.

    And one last comment on your question: using session for keeping navigation state is not generally a good thing. It depends on your configuration but sessions can be shared between two browser tabs – and then the navigation can get pretty messy. And don’t forget the dreadful Back button.

    So my opinion is that you really should not use generic route.

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

Sidebar

Related Questions

Scheme relative URLs (network-path references) are something that I've just found out about -
With relative newness to AJAX, and now just starting to learn PDO, the added
I am currently a relative layout is shown in a listview . Turns out
I'm a relative rails newbie, just getting started on learning how to DRY my
I'm a beginner at rails programming, attempting to show many images on a page.
I am a relative beginner at git - I have two branches: master and
I'm a relative beginner with OpenGL (I'm not counting the ver. 1.1 NeHe tutorials
I am a total beginner, so excuse my inability to see an obvious solution
I'm a relative beginner to PHP and I'm having an issue with a web
I am a relative beginner with C. I have written what I think is

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.