[newbie] formatting web-link in list.rhtml


#1

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)

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


#2

rob rob wrote:

is of course 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 :frowning:

Not sure, but is this not a job for link_to_remote?
Cheers
Mohit


#3

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

Mike


#4

rob rob escribió:

is of course 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 :frowning:

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


#5

Mohit S. wrote:

the destination is http://www.my_own_homepage/www.homepage.nl (what I
want is of course 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 :frowning:

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.


#6

Rafa wrote:

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

That works, tanks!!!

Was it wrong to use a string for this?


#7

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.


#8

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

…either way’s gooood.
cheers too.

s