Externe Links mit Ruby on Rails

30.07.2010 00:07 Gregor Panek Ruby on Rails 26

Einen Externen Link in Rails zu erstellen sollte eigentlich kein Problem darstellen. Jedoch kann es in Frust ausarten wenn man zwei, im nachhinein recht simple Dinge nicht beachtet.

Externen Link erstellen

Genau mit diesem Problem hatte ich am Anfang auch zu kämpfen. Wie erstelle ich einen Externen Link auf eine andere Webseite? Einen einfachen Link der auf eine Interne Seite zeigt erstellt man üblicherweise so:

<%=link_to "Name des Links", root_path%>  </pre>

Das vorgehen bei einem Externen Link ist eigentlich genauso, nur das man zum einen eine Option (target) hinzufügen muss und zum anderen darauf achten das der externe Link mit http:// beginnt.

<%=link_to "Google", "http://www.google.de", :target => "_blank"%> 

Dadurch erhält man einen Link der Google in einem neuen Tab öffnet. Die möglichen Optionen für das Element Target können aus der HTML Syntax entnommen werden.

Vergisst man http:// vor der Url, so wird der Pfad zum Link einfach nur an die Url der aktuellen Seite hinzugefügt, was natürlich beim Aufruf zu einem Fehler führt, da die Seite nicht gefunden werden kann.

Zurück

26 Kommentare zu Externe Links mit Ruby on Rails

gravatar

moncler to buy online
05.11.2014 04:39:56

Hey there! Someone in my Myspace group shared this site with us so I came to check it out. I'm definitely enjoying the information. I'm bookmarking and will be tweeting this to my followers! Outstanding blog and wonderful design and style.


gravatar

Karine
29.06.2017 04:53:06

I think this is among the most vital information for me. And i'm glad reading your article. But wanna remark on some general things, The website style is perfect, the articles is really excellent : D. Good job, cheers


gravatar

Jared
08.10.2018 11:23:39

This is very fascinating, You are an excessively skilled blogger. I have joined your feed and sit up for looking for extra of your magnificent post. Additionally, I've shared your web site in my social networks


gravatar

Wilbur
10.10.2018 00:28:50

I am regular visitor, how are you everybody? This paragraph posted at this site is really pleasant.


gravatar

Sanora
11.10.2018 17:13:23

An intriguing discussion is worth comment. I do think that you should write more on this subject matter, it may not be a taboo matter but usually people do not discuss such issues. To the next! Kind regards!!


gravatar

Parthenia
12.10.2018 18:05:04

What's up to every one, the contents existing at this web page are really remarkable for people knowledge, well, keep up the good work fellows.


gravatar

Jonelle
15.10.2018 07:46:32

Are you looking to see and talk to some really sexy girls? These girls are super dirty and it doesn’t cost a single cent to talk to them. It’s wall to wall babes at this site. Just visit https://t.irtyc.com/cvezzegjk?aff_id=29696&offer_id=3664&bo=2779,2778,2777,2776,3391 and sign up for your free account. You’ll be talking to these total babes in a matter of no time flat!


gravatar

Kenton
20.10.2018 13:06:25

There’s been a lot of changes since I last left a comment about my site. I’m starting to add the new features that I’ve wanted to. I hope in the next few weeks that all of it will be up and running. It’s going to take time and I haven’t had much of it to dedicate to this project. I thank you all for visiting my site and I hope you have a great weekend!


gravatar

Phillipp
24.10.2018 14:22:18

There’s been a lot of changes since I last left a comment about my site. I’m starting to add the new features that I’ve wanted to. I hope in the next few weeks that all of it will be up and running. It’s going to take time and I haven’t had much of it to dedicate to this project. I thank you all for visiting my site and I hope you have a great weekend!


gravatar

Coy
28.10.2018 13:46:24

Watch this amazing video of Ronaldo saving the game http://corneey.com/wZLrVn This is why he’s one of the best football players to ever live!


gravatar

Alex
09.11.2018 11:25:37

Have you heard Ariana Grande perform Thank U live? If not, then you’ve definitely got to hear it. Give it a listen by clicking here http://kudoflow.com/4Emv This might just be her best song ever!


gravatar

Theodore
14.01.2019 21:27:02

I know this web page gives quality depending posts and extra data, is there any other web page which gives these kinds of information in quality?


gravatar

카지노사이트
12.02.2019 11:19:34

I definitely loved every bit of it. I have you saved as a favorite to look at new stuff you post…


gravatar

우리카지노
12.02.2019 11:49:04

What’s up to every one, the contents present at this web page are genuinely amazing for people experience, well, keep up the good work fellows.


gravatar

카지노사이트
12.02.2019 11:57:05

Interesting. I have been looking around different blogs for information. I love using this site for fun. Great way to help learn!


gravatar

Ulrich
26.03.2019 08:51:22

Fantastic beat ! I wish to apprentice while you amend your web site, how can i subscribe for a blog website? The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear concept


gravatar

Camille
13.04.2019 08:16:52

Hi Dear, are you in fact visiting this site daily, if so then you will absolutely get good experience.


gravatar

Louella
15.04.2019 17:57:07

Wow that was strange. I just wrote an incredibly long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Anyway, just wanted to say superb blog!


gravatar

Johnette
18.04.2019 17:00:32

Thanks for the auspicious writeup. It in reality was a leisure account it. Look advanced to more introduced agreeable from you! By the way, how could we keep in touch?


gravatar

Lupe
18.04.2019 19:55:35

We're a group of volunteers and starting a new scheme in our community. Your web site offered us with useful info to work on. You have performed an impressive activity and our entire group will probably be thankful to you.


gravatar

Victorina
22.04.2019 19:37:42

Wonderful goods from you, man. I have understand your stuff previous to and you're just too great. I actually like what you have acquired here, really like what you're stating and the way in which you say it. You make it entertaining and you still care for to keep it smart. I cant wait to read much more from you. This is actually a tremendous web site.


gravatar

Carrol
23.04.2019 18:49:56

You actually make it appear really easy with your presentation but I in finding this matter to be really something that I believe I might never understand. It sort of feels too complex and extremely extensive for me. I'm taking a look forward to your subsequent submit, I'll try to get the cling of it!


gravatar

Leonard
26.04.2019 11:32:30

You really make it seem so easy with your presentation but I find this topic to be really something that I think I would never understand. It seems too complicated and very broad for me. I'm looking forward for your next post, I will try to get the hang of it!


gravatar

Maurine
27.04.2019 02:37:59

obviously like your web site but you need to take a look at the spelling on quite a few of your posts. A number of them are rife with spelling problems and I to find it very bothersome to inform the reality then again I'll certainly come back again.


gravatar

Winfred
29.04.2019 05:59:43

always i used to read smaller articles or reviews that as well clear their motive, and that is also happening with this article which I am reading at this time.


gravatar

Reagan
20.05.2019 20:41:35

These are actually enormous ideas in about blogging. You have touched some pleasant things here. Any way keep up wrinting.

Kommentar abgeben