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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:58:37+00:00 2026-05-14T23:58:37+00:00

Linking to external file in Ruby on Rails I have a file I want

  • 0

Linking to external file in Ruby on Rails

I have a file I want to share as a link in my rails app.
I create a link to it in the .erb file like this

<li><a href="somefile.pdf">Some File</a> </li>

When I select the link I get the following error.

Routing Error

No route matches “/pages/somefile.pdf”
with {:method=>:get}

Do I really need a route for this? I really just want the save as dialog to popup. Just a link to a file that the user can open or download.

What is the rails way to do this (rails newbie here)?

  • 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-14T23:58:38+00:00Added an answer on May 14, 2026 at 11:58 pm

    You should place the file in the app’s public/ directory and use a forward slash at the start of the path in your link’s href.

    The problem you are having is because href="somefile.pdf" is relative to the current URL which is probably something like http://localhost:3000/pages/42. By using href="/somefile.pdf" instead the resolved URL will be http://localhost:3000/somefile.pdf (rather than http://localhost:3000/pages/somefile.pdf) and it won’t conflict with your pages routes.

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

Sidebar

Related Questions

I can't link external css file to html The HTML file is situated in
SVG standard allows to use and refer external SVG files. I have a file
I have a Delphi unit that is statically linking a C .obj file using
I have a java application and it needs linking some external library( actually jar
I'm newbie to TypoScript. I actually don't know how to make link like this:
I previously had this problem with an external file not running. I fixed this
For some reason the external .js file I am linking to isn't working. I
I am getting the following linking error : libOpenSSL.lib(cryptlib.obj) : error LNK2001: unresolved external
In linking a sports event to two teams, at first this seemed to make
//deep linking $.fn.ajaxAnim = function() { $(this).animW(); $(this).html('<div class=load-prog>loading...</div>'); } $(document).ready(function(){ contM = $('#main-content');

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.