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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:21:39+00:00 2026-05-15T03:21:39+00:00

I was wondering if there’s anyway to get a ‘dynamic path’ into a .js

  • 0

I was wondering if there’s anyway to get a ‘dynamic path’ into a .js file through Ruby on Rails.

For example, I have the following:

new Ajax.Request('/tokens/destroy/' + GRID_ID, {asynchronous:true, evalScripts:true, onComplete:function(request){load('26', 'table1', request.responseText)}, parameters:'token=' + dsrc.id + '&authenticity_token=' + encodeURIComponent(AUTH_TOKEN)})

The main URL is ‘/tokens/destroy/:id’, however on my production server this app runs as a sub folder. So the URL for this ajax call needs to be ‘/qrpsdrail/tokens/destroy/:id’

The URL this is being called from would be
/grids/1 or /qrpsdrail/grids/1

I could, of course, do ../../path — but that seems a bit hackish. It is also dependent on the routing never changing, which at this stage I can’t guarantee.
I’m just interested in seeing what other solutions there might be to this problem.

Thanks in advance 🙂

  • 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-15T03:21:40+00:00Added an answer on May 15, 2026 at 3:21 am

    Maybe a bit hackish solution, but i have a configuration-file like described here, and so you could do something like, inside a config.yml :

    development:
      root: /
    
    production:
      root: /qrpsdrail/
    

    and when you build your Ajaxrequest, you could write

    new Ajax.Request("#{AppConfig.root}tokens/destroy/' + ...
    

    But it still looks like there should be a cleaner way to solve this 😉

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

Sidebar

Related Questions

Im wondering if there is anyway that you can get the absolute location of
Just wondering if there is any way (in C) to get the contents of
Wondering if there is a way to get the amount of rows returned from
Wondering if there is a way to have multicolor text for ASP.NET Button Text.
HI there I was wondering if there is anyway to combine all Contract.Requiere in
Just wondering if there's a way to run Rails tests without dropping the database.
wondering if there's any way to make it so that a list I have
Wondering if there is a way to send a Screenshot of sorts through a
Just wondering whether there is a way to insert a bulk text message into
I am just wondering is there a way to get the value of a

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.