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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:35:46+00:00 2026-05-13T12:35:46+00:00

I am attempting to create a custom route in rails and am not sure

  • 0

I am attempting to create a custom route in rails and am not sure if I am going about it in the right way. Firstly I have a RESTful resource for stashes that redirects to mystash as the controller:

map.resources :stashes, :as => 'mystash'
site.com/mystash goes to :controller => 'stashes', :action => 'show'

Which is what I want. Now is where it gets somewhat confusing. I would like to be able to add conditional params to this route. Ultimately I would like to have a route that looks like this:

site.com/mystash/zoomout/new/quiz_on/

I have places this in routes:

map.connect 'mystash/:zoom/:nav_option/:quiz',
            :controller => 'stashes',
            :action => 'show'    
map.connect 'mystash/:zoom/:nav_option',
            :controller => 'stashes',
            :action => 'show'
map.connect 'mystash/:zoom',
            :controller => 'stashes',
            :action => 'show'
map.connect 'mystash',
            :controller => 'stashes',
            :action => 'show'

My routes have ended up looking like this in the browser:
site.com//mystash/zoomin?nav_option=New&quiz=quizon

and this is what one of my links looks like:

<%= link_to "In", stash_path("zoomin", :nav_option => @nav_option, :quiz => @quiz) %>

Any help is appreciated, I am pretty new to custom routes!

  • 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-13T12:35:46+00:00Added an answer on May 13, 2026 at 12:35 pm

    You should be giving these routes different names instead of the default, or you should be specifying your route with a hash and not a X_path call. For instance:

    map.stash_zoom_nav_quiz 'mystash/:zoom/:nav_option/:quiz',
      :controller => 'stashes',
      :action => 'show'    
    map.stash_zoom_nav 'mystash/:zoom/:nav_option',
      :controller => 'stashes',
      :action => 'show'
    

    Keep in mind that when you declare a named route, the parameters in the path must be specified in the X_path call with no omissions, and not as a hash.

    link_to('Foo', stash_zoom_nav_quiz_path(@zoom, @nav_option, @quiz))
    link_to('Bar', stash_zoom_nav_path(@zoom, @nav_option))
    

    The alternative is to not bother with named routes and let the routing engine figure it out on its own:

    link_to('Foo', :controller => 'stashes', :action => 'show', :zoom => @zoom, :nav_option => @nav_option, :quiz => @quiz)
    

    If you’re uncertain what routes are defined, or how to call them, always inspect the output of “rake routes” very carefully. You can also write functional tests for routes with the assert_routing method.

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

Sidebar

Related Questions

I am attempting to create a custom tableview where I have a list of
I'm attempting to create a custom validation for one of my models in Rails
I attempting to create custom tabs using this . But when I try to
I am attempting to create custom colors of the tabs in a TabHost. I
I am attempting to create a custom Adapter for my ListView since each item
I am attempting to create my own custom Autocomplete style dropdown control in c#
So, horray - I'm attempting to create a new custom Payment Gateway. It's designed
I am attempting to create a custom android style xml. And while everyone else
I'm attempting to create a custom cell renderer for my GWT CellTable. I'm attempting
I am attempting to create a custom attribute that can be assigned to an

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.