# \[newbie\] formatting web-link in list.rhtml

**URL:** <https://www.ruby-forum.com/t/newbie-formatting-web-link-in-list-rhtml/63362>\
**Category:** Rails\
**Created:** [June 14, 2006, 4:18pm UTC](https://www.ruby-forum.com/t/newbie-formatting-web-link-in-list-rhtml/63362 "2006-06-14T16:18:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![robredford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@robredford](https://www.ruby-forum.com/u/robredford)\
**Post date:** [June 14, 2006, 4:18pm UTC](https://www.ruby-forum.com/t/newbie-formatting-web-link-in-list-rhtml/63362/1 "2006-06-14T16:18:54Z")

</div>

Perhaps I need a break, but I can’t find the answer for this simple  
question.

I have a database which also contains an internet address. I want to  
show this address with a link (wich is named link).

When I do;

\<%= link\_to ‘link’, camping.website %\> I get a clickable link. But the  
destination is http://www.my\_own\_homepage/www.homepage.nl (what I want  
is of course [http://www.homepage.nl](http://www.homepage.nl))

I have tried a lot of options, and I am already googling for hours, but  
I can’t get this simple task done ☹

---

<div class="post-metadata">

**Author:** ![robredford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@robredford](https://www.ruby-forum.com/u/robredford)\
**Post date:** [June 14, 2006, 4:24pm UTC](https://www.ruby-forum.com/t/newbie-formatting-web-link-in-list-rhtml/63362/2 "2006-06-14T16:24:44Z")

</div>

rob rob wrote:

> is of course [http://www.homepage.nl](http://www.homepage.nl))
> 
> I have tried a lot of options, and I am already googling for hours, but  
> I can’t get this simple task done ☹

Not sure, but is this not a job for link\_to\_remote?  
Cheers  
Mohit

---

<div class="post-metadata">

**Author:** ![robredford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@robredford](https://www.ruby-forum.com/u/robredford)\
**Post date:** [June 14, 2006, 4:30pm UTC](https://www.ruby-forum.com/t/newbie-formatting-web-link-in-list-rhtml/63362/3 "2006-06-14T16:30:58Z")

</div>

what you’re doing should be correct. Have you tried printing the  
value of camping.website? Is it a string?

Mike

---

<div class="post-metadata">

**Author:** ![robredford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@robredford](https://www.ruby-forum.com/u/robredford)\
**Post date:** [June 14, 2006, 4:40pm UTC](https://www.ruby-forum.com/t/newbie-formatting-web-link-in-list-rhtml/63362/4 "2006-06-14T16:40:39Z")

</div>

rob rob escribiÃ³:

> is of course [http://www.homepage.nl](http://www.homepage.nl))

This change is normally done by the server because you didn’t write  
“http://”

> I have tried a lot of options, and I am already googling for hours, but  
> I can’t get this simple task done ☹

Try this one:  
Concatenate to the link this string: “http://”

Bye,

```
                                          Rafael G.

```

* * *

LLama Gratis a cualquier PC del Mundo.  
Llamadas a fijos y móviles desde 1 céntimo por minuto.  
[http://es.voice.yahoo.com](http://es.voice.yahoo.com)

---

<div class="post-metadata">

**Author:** ![robredford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@robredford](https://www.ruby-forum.com/u/robredford)\
**Post date:** [June 14, 2006, 4:34pm UTC](https://www.ruby-forum.com/t/newbie-formatting-web-link-in-list-rhtml/63362/5 "2006-06-14T16:34:23Z")

</div>

Mohit S. wrote:

> > the destination is http://www.my\_own\_homepage/www.homepage.nl (what I  
> > want is of course [http://www.homepage.nl](http://www.homepage.nl))
> > 
> > I have tried a lot of options, and I am already googling for hours,  
> > but I can’t get this simple task done ☹
> 
> Not sure, but is this not a job for link\_to\_remote?  
> Cheers  
> Mohit  
> I just did some looking around and I think I’ve got my concepts muddled  
> up… :-S  
> Ignore my previous message… sorry, guys!  
> I’m going back to the books…  
> Cheers  
> Mohit.

---

<div class="post-metadata">

**Author:** ![robredford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@robredford](https://www.ruby-forum.com/u/robredford)\
**Post date:** [June 14, 2006, 4:48pm UTC](https://www.ruby-forum.com/t/newbie-formatting-web-link-in-list-rhtml/63362/6 "2006-06-14T16:48:07Z")

</div>

Rafa wrote:

> Try this one:  
> Concatenate to the link this string: “http://”

That works, tanks!!!

Was it wrong to use a string for this?

---

<div class="post-metadata">

**Author:** ![robredford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@robredford](https://www.ruby-forum.com/u/robredford)\
**Post date:** [June 14, 2006, 4:42pm UTC](https://www.ruby-forum.com/t/newbie-formatting-web-link-in-list-rhtml/63362/7 "2006-06-14T16:42:28Z")

</div>

camping.website is indeed a string. When I do:

\<%= link\_to camping.website %\> It shows the right website, but it links  
to my own.

When I do:

\<%= auto\_link camping.website %\> It shows the right website, and it  
links to the right website. I only don’t have a link with the name link.

---

<div class="post-metadata">

**Author:** ![robredford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ea924/32.png) [@robredford](https://www.ruby-forum.com/u/robredford)\
**Post date:** [June 14, 2006, 5:08pm UTC](https://www.ruby-forum.com/t/newbie-formatting-web-link-in-list-rhtml/63362/8 "2006-06-14T17:08:58Z")

</div>

no point in adding a gsub on the string would have worked to  
yourstr.gsub(‘[http://http](http://http)://’, ‘http://’) …or place [http://www](http://www) twice  
etc

…either way’s gooood.  
cheers too.

s
