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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:49:49+00:00 2026-05-25T23:49:49+00:00

I have a route setup for downloading a document which I need a named

  • 0

I have a route setup for downloading a document which I need a named parameter for the document name so I get the doc name on the download document. I’m also passing a few unnamed parameters to identify the document.

Looks like this:

match "download/:name", :to => 'documents#download', :as => "doc_download"

And I have my link setup like this:

<%= link_to doc.pdf_name, doc_download_url(doc.pdf_name, 
    :prefix => doc.doc_prefix,:num => doc.doc_num, :change => doc.doc_change) %>

When I run the page I get the following error:

No route matches {:controller=>"documents", :action=>"download", 
    :prefix=>"D", :num=>"002", :change=>0, :name=>"sdr_vor_000.pdf"}

The weird thing is the route shows up in my rake routes:

doc_download  /download/:name(.:format) {:controller=>"documents", :action=>"dow
    nload"}

Ideas?

Also if I remove the name parameter or make it optional, it works, but doesn’t stick the name into the url. It just gets tacked onto the query string.

  • 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-25T23:49:50+00:00Added an answer on May 25, 2026 at 11:49 pm

    Your name parameter contains a period – by default, the part after the period is interpreted as the format, not part of the name parameter. To allow periods in the filename, amend your route like this (tweak the regex to your needs):

    match "download/:name", :to => 'documents#download', 
      :constraints => { :name => /[a-z0-9\.]+/i }, :as => "doc_download"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this routing setup at the moment routes.MapRoute( OldPages, // Route name page{id}.html,
I have a route: routes.MapRoute( Company, {id}/{name}.aspx, new { controller = Company, action =
I have a route like following, ideally I would like it to match: domain.com/layout/1-slug-is-the-name-of-the-page
I have a route which routes a request to somepath/:id(.:format) to somecontroller#show . This
I have a route defined like this: GET /question/:q_id controllers.Questions.viewQuestion(q_id: Long) Then in my
I have the following route: routes.MapRoute( Default, // Route name {controller}/{action}/{id}, // URL with
I have a catch-all route setup in ASP.NET MVC, so I can capture /this-page,
I am struggling with the route setup for a Rails application. I have installed
I'd like to have a route setup like the following routes.MapRoute( Static content handler,
Sorry, this is along one to document.. OLD SETUP I have a J2ME client

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.