# Eval(hyperlink) question

**URL:** <https://www.ruby-forum.com/t/eval-hyperlink-question/231759>\
**Category:** Rails\
**Created:** [August 28, 2014, 3:14pm UTC](https://www.ruby-forum.com/t/eval-hyperlink-question/231759 "2014-08-28T15:14:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [August 28, 2014, 3:14pm UTC](https://www.ruby-forum.com/t/eval-hyperlink-question/231759/1 "2014-08-28T15:14:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [August 28, 2014, 4:34pm UTC](https://www.ruby-forum.com/t/eval-hyperlink-question/231759/2 "2014-08-28T16:34:32Z")

</div>

On 28 August 2014 14:14, Dave C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [August 28, 2014, 4:52pm UTC](https://www.ruby-forum.com/t/eval-hyperlink-question/231759/3 "2014-08-28T16:52:49Z")

</div>

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](http://www.somewhere.com)” in the  
current directory, _not_ a link to the site [www.somewhere.com](http://www.somewhere.com). You need  
an explicit method, e.g.:

[](http://www.somewhere.com/)
## ~Chris

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

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [August 28, 2014, 7:31pm UTC](https://www.ruby-forum.com/t/eval-hyperlink-question/231759/4 "2014-08-28T19:31:43Z")

</div>

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](http://www.somewhere.com)” in the  
> current directory, _not_ a link to the site [www.somewhere.com](http://www.somewhere.com). You need  
> an explicit method, e.g.:
> 
> [ 
> ## ~Chris
> ](http://www.somewhere.com/)
> 
> [Chris Maden, text nerd \<URL:](http://www.somewhere.com/)[http://crism.maden.org/](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

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [August 29, 2014, 2:33pm UTC](https://www.ruby-forum.com/t/eval-hyperlink-question/231759/5 "2014-08-29T14:33:00Z")

</div>

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](http://www.somewhere.com)” in the  
> > current directory, _not_ a link to the site [www.somewhere.com](http://www.somewhere.com). You need  
> > an explicit method, e.g.:
> > 
> > [ 
> > 
> > ~Chris
> > 
> > ](http://www.somewhere.com/)
> 
> [](http://www.somewhere.com/)

[ 

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:

 ](http://www.somewhere.com/)

[question = “](http://www.somewhere.com/)[index of  
refraction](http://www.cnn.com) 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

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [August 29, 2014, 8:32pm UTC](https://www.ruby-forum.com/t/eval-hyperlink-question/231759/6 "2014-08-29T20:32:49Z")

</div>

Am 29.08.2014 14:33 schrieb “Dave C.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > > current directory, _not_ a link to the site [www.somewhere.com](http://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/](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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> To post to this group, send email to [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/rubyonrails-talk/9f70371fc4d5ba77a6ce43191d76df9b%40ruby-forum.com](https://groups.google.com/d/msgid/rubyonrails-talk/9f70371fc4d5ba77a6ce43191d76df9b%40ruby-forum.com)  
> .
