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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:33:51+00:00 2026-06-05T17:33:51+00:00

I added a configuration variable in application.rb such as module Www class Application <

  • 0

I added a configuration variable in application.rb such as

module Www
    class Application < Rails::Application
      ...
      config.myurl = "http://localhost:8443/play"
end

After something is clicked on my page I would like to use the value of this config var in order to come up with my full url such as mypage.js having

function ClickedOnSomething(someid){
    var fullUrl = <value of config.myurl> + '?id='+someid+'.html'; 
    ...
}

so that if for example the id of what I clicked on was 1776 then the fullUrl would be the string
http://localhost:8443/play?id=1776.html

I am using Ruby on Rails 3.2.3 and Ruby 1.9.3

One thing I tried was going through the controller like the following:

In application_controller.rb I added

def before_filter
  # This variable will be available in all controller actions and views
  @url_global = Www::Application.config.myurl
end

In application.html.erb I added

<script type="text/javascript">
  var url_global = "<%= @url_global %>"
</script>

Then in mypage.js I did

function ClickedOnSomething(someid){
    var fullUrl = @url_global + '?id='+someid+'.html'; 
    ...
}

but @url_global is not recognized. I have actually tried many different variations of using the var in javascript but nothing is working for me.

  • 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-06-05T17:33:54+00:00Added an answer on June 5, 2026 at 5:33 pm

    I saw you declare

    var url_global = "<%= @url_global %>";
    

    so you have to use url_global in function, not @url_global;

    var fullUrl = url_global + '?id='+someid+'.html'; 
    

    Am I correct?

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

Sidebar

Related Questions

I have added some settings to my c# application using the configuration editor. There
I have MVC 1.0 app with VS2008. I have added configuration to web.config but
I've added the following parameter in Config.groovy storeFront.cms.endpoint = http://10.60.33.51:27110/file_source I'm trying to read
I added Jquery toggle/show hide in my site (click the plus sign) http://pligg.marsgibson.info if
I've set up a new database config in application/config/database.php called staff . I've then
I want to adjust the output from my TeamCity build configuration of my class
After installation completes, the Rails Environment configuration window pops up: The system cannot find
I've added x64 configuration to my C++ project to compile 64-bit version of my
i'm trying to use Mongoid with rails 3.2.2, i've added: gem mongoid, ~> 2.4
I've installed Xcache 2.0.0 module on mac osx 10.7.3 , added it's configurations to

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.