Eval(hyperlink) question

Hi,

The hyperlink below is being evaluated to “questions/www.somewhere.com”:

q = eval(question) # Converts the question string from the database back
into code.
formatted = {
question: q[“question”],

}
end

question ="
… from a light source is equal to the index of refraction (n) divided by the
distance (in meters) of the light rays…"

Can anyone point me in the right direction as to why “questions” is
being prepended to the route and how to avoid that from happening.

Thanks,
Dave C., MD

On 28 August 2014 14:14, Dave C. [email protected] wrote:

distance (in meters) of the light rays…"

Can anyone point me in the right direction as to why “questions” is
being prepended to the route and how to avoid that from happening.

What is the content of q after assigning the eval to it? As you have
described it I would have expected that to generate a runtime error:
1.8.7-p374 :003 > question =“… from a light source is equal to the
href=‘www.somewhere.com’>index of refraction (n) divided by
the distance (in meters) of the light rays…”
=> “… from a light source is equal to the
href=‘www.somewhere.com’>index of refraction
(n) divided by the
distance (in meters) of the light rays…”
1.8.7-p374 :004 > eval(question)
SyntaxError: (eval):1:in `irb_binding’: compile error
(eval):1: syntax error, unexpected tDOT3
… from a light source is equal …
^

Colin

On 08/28/2014 08:14 AM, Dave C. wrote:

Can anyone point me in the right direction as to why “questions” is
being prepended to the route and how to avoid that from happening.

This is a basic HTML problem, not a Rails one.

Your link is a relative link to the file “www.somewhere.com” in the
current directory, not a link to the site www.somewhere.com. You need
an explicit method, e.g.:

~Chris

Chris Maden, text nerd <URL: http://crism.maden.org/ >
Surround hate and force it to surrender.
GnuPG fingerprint: DB08 CF6C 2583 7F55 3BE9 A210 4A51 DBAC 5C5C 3D5E

Christopher R. Maden wrote in post #1156206:

On 08/28/2014 08:14 AM, Dave C. wrote:

Can anyone point me in the right direction as to why “questions” is
being prepended to the route and how to avoid that from happening.

This is a basic HTML problem, not a Rails one.

Your link is a relative link to the file “www.somewhere.com” in the
current directory, not a link to the site www.somewhere.com. You need
an explicit method, e.g.:

~Chris

Chris Maden, text nerd <URL: http://crism.maden.org/ >
Surround hate and force it to surrender.
GnuPG fingerprint: DB08 CF6C 2583 7F55 3BE9 A210 4A51 DBAC 5C5C 3D5E

Thanks! That did the trick.

Left most of q = eval out of post Colin.

Dave

Dave C. wrote in post #1156219:

Christopher R. Maden wrote in post #1156206:

On 08/28/2014 08:14 AM, Dave C. wrote:

Can anyone point me in the right direction as to why “questions” is
being prepended to the route and how to avoid that from happening.

This is a basic HTML problem, not a Rails one.

Your link is a relative link to the file “www.somewhere.com” in the
current directory, not a link to the site www.somewhere.com. You need
an explicit method, e.g.:

~Chris

A quick follow up question?

I would like to open the link in a new window but the following opens
the link on the current tab:

question = “index of
refraction
What is the vergence of the light rays in the image at
reference plane (y), #{distance_in_cm.round(2)} cm from the light
source?”

It seems to be ignoring the target= ‘_blank’. Is this a single quotes
inside double quotes issue?

Thanks again,

Dave

Am 29.08.2014 14:33 schrieb “Dave C.” [email protected]:

current directory, not a link to the site www.somewhere.com. You
need
the link on the current tab:
You can’t do that with guarantee, some browsers don’t even know about
windows or tabs (links, lynx) others are configurable in that matter.

Dave


Posted via http://www.ruby-forum.com/.


You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/9f70371fc4d5ba77a6ce43191d76df9b%40ruby-forum.com
.