# Two link Questions

**URL:** <https://www.ruby-forum.com/t/two-link-questions/168820>\
**Category:** Rails\
**Created:** [May 26, 2009, 12:26pm UTC](https://www.ruby-forum.com/t/two-link-questions/168820 "2009-05-26T12:26:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![df-sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@df-sean](https://www.ruby-forum.com/u/df-sean)\
**Post date:** [May 26, 2009, 12:26pm UTC](https://www.ruby-forum.com/t/two-link-questions/168820/1 "2009-05-26T12:26:38Z")

</div>

I want a user to be able to submit a link to an outside website. If it  
is an article titled say “Lakers lose to Denver.” from the New York  
Times, I want to create a link to the article, but have the title of the  
button be the name of the article.

Also I want to include the source website, but have it not be a button.  
If the user submits a link that says  
[www.nyt.com/sports/basketball/32445](http://www.nyt.com/sports/basketball/32445), I want this to be shorted  
automatically to [www.nyt.com](http://www.nyt.com)

---

<div class="post-metadata">

**Author:** ![df-sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@df-sean](https://www.ruby-forum.com/u/df-sean)\
**Post date:** [May 26, 2009, 6:42pm UTC](https://www.ruby-forum.com/t/two-link-questions/168820/2 "2009-05-26T18:42:15Z")

</div>

I have the information stored in a table called articles. The title is  
under “title” and the url under “url”

I can use the auto\_link method with url, for example:  
\<%= auto\_link @article.url %\>

I want the button to say the title field, but link to the url field.  
I thought it might be something like \<%= auto\_link ‘title’, ‘url’ %\>  
But I guess I need to write some kind of helper method, which is where I  
am confused.

---

<div class="post-metadata">

**Author:** ![df-sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@df-sean](https://www.ruby-forum.com/u/df-sean)\
**Post date:** [May 26, 2009, 9:12pm UTC](https://www.ruby-forum.com/t/two-link-questions/168820/3 "2009-05-26T21:12:10Z")

</div>

Just \<%= link\_to title, url %\> greetings, mike

2009/5/26, Sean S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ## am confused.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Von meinen Mobilgerät aus gesendet

---

<div class="post-metadata">

**Author:** ![df-sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@df-sean](https://www.ruby-forum.com/u/df-sean)\
**Post date:** [May 27, 2009, 4:40am UTC](https://www.ruby-forum.com/t/two-link-questions/168820/4 "2009-05-27T04:40:43Z")

</div>

If I try this: \<%= link\_to(@article.title, @article.url) %\>  
I almost get it. Say the title is “google” and the url is  
[www.google.com](http://www.google.com); I get a button that says google, but it links to  
localhost:articles/1/www.google.com, not [www.google.com](http://www.google.com)
