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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:31:26+00:00 2026-06-03T17:31:26+00:00

I am trying to embed the output of Ruby code in JavaScript: var stuff=

  • 0

I am trying to embed the output of Ruby code in JavaScript:

var stuff= "<% Representative.get('http://0.0.0.0:4568/') %>";

The embedded part is working by itself showing a result like this:

{ "name":"John Johnson", "street":"Oslo West 555", "age":33, "phone":"555 1234567"} 

The line above is the EXACT PAGE SOURCE; it runs locally though, so I can’t show you the page.

When in a variable, I try to send it to my application with this:

document.getElementById("X_Axis").value=stuff.name;

through the input:

<input type="text" id="X_Axis" />

I get a undefined value every time.

I tried hardcoding the value in the JavaScript and it works fine like that, put when the embedded Ruby is put into the JavaScript variable, it always gives me the undefined value.

  • 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-03T17:31:27+00:00Added an answer on June 3, 2026 at 5:31 pm

    You shouldn’t be putting quotes around your ERB code, otherwise it puts the results in a string instead of assigning it to stuff as a hash/JSON object. Remove them and it should work. (Also, <% should be <%=).

    var stuff = <%= Representative.get('http://0.0.0.0:4568/') %>;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert a camtasia html/javascript video embed code to a wordpress flowplayer
I'm trying to embed this player to a web page: http://musicplayer.sourceforge.net/ It's working fine,
I am trying to embed a flash file onto the homepage of my Ruby
im trying to echo mediaplayer embed code with IF statement. is there any way
I'm trying to embed binary media resources into source code. I will going to
As part of a larger project, I'm trying to embed a Python interactive interpreter
I'm trying to make the embed by using AJAX to call the embed code
I am trying to embed Facebook video using the code below: <object width=400 height=224
I'm trying to embed a variable in a block of code that I'm writing
I am trying to embed swf to html, and I'm using SwfObject 2.0 My

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.