# ActionView::Helpers::TextHelper - auto\_link

**URL:** <https://www.ruby-forum.com/t/actionview-texthelper-auto-link/90098>\
**Category:** Rails\
**Created:** [March 26, 2007, 2:46am UTC](https://www.ruby-forum.com/t/actionview-texthelper-auto-link/90098 "2007-03-26T02:46:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samantha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Samantha](https://www.ruby-forum.com/u/Samantha)\
**Post date:** [March 26, 2007, 2:46am UTC](https://www.ruby-forum.com/t/actionview-texthelper-auto-link/90098/1 "2007-03-26T02:46:36Z")

</div>

Hi there,

I’m working on something in Rails (my first app, really) and  
attempting to use the auto\_link feature. Basically, one of the fields  
in my database is a url. I have successfully gotten it to format in  
the view with the auto\_link helper, but when it comes time for me to  
try and input the :target =\> ‘\_blank’ part of things, it craps out on  
me.

This is the code that works:

\<%= auto\_link(h link.send(column.name)) %\>

When I attempt to have it use the :target =\> ‘\_blank’ stuff, is where  
I’m getting lost…

If I change it to this: (or several other syntax variations)

\<%= auto\_link(h link.send(column.name), :target =\> '\_blank') %\>

I get this:

wrong number of arguments (2 for 1)  
Extracted source (around line #13):  
10: \<% for link in @links %\>  
11:   
12: \<% for column in Link.content\_columns %\>  
13: \<%= auto\_link(h link.send(column.name), :target =\>  
‘\_blank’) %\>  
14: \<% end %\>  
15: \<%= link\_to ‘Show’, :action =\> ‘show’, :id =\> link %\>  
16: \<%= link\_to ‘Edit’, :action =\> ‘edit’, :id =\> link %\>

I’ve looked here:

> **[ActionView::Helpers::TextHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html)**
>
> The TextHelper module provides a set of methods for filtering, formatting and transforming strings, which can reduce the amount of inline Ruby code in your views.

I’m pretty sure it’s probably something glaringly obvious that I’m  
missing, but rather than bang my head incessantly on my keyboard, I  
figured I’d save myself the qwerty imprints on my forehead and  
ask. 🙂

Thanks,  
Samantha

–  
[http://www.babygeek.org](http://www.babygeek.org)

---

<div class="post-metadata">

**Author:** ![Samantha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Samantha](https://www.ruby-forum.com/u/Samantha)\
**Post date:** [March 26, 2007, 6:46am UTC](https://www.ruby-forum.com/t/actionview-texthelper-auto-link/90098/2 "2007-03-26T06:46:39Z")

</div>

Hi,

Try:

auto\_link(h(link.send(column.name)), :target =\>\> ‘\_blank’)

The h function needed to be wrapped in parens ().

Hope this helps!

Shawn

Samantha wrote:

> Hi there,
> 
> I’m working on something in Rails (my first app, really) and  
> attempting to use the auto\_link feature. Basically, one of the fields  
> in my database is a url. I have successfully gotten it to format in  
> the view with the auto\_link helper, but when it comes time for me to  
> try and input the :target =\> ‘\_blank’ part of things, it craps out on  
> me.
> 
> This is the code that works:
> 
> \<%= auto\_link(h link.send(column.name)) %\>
> 
> When I attempt to have it use the :target =\> ‘\_blank’ stuff, is where  
> I’m getting lost…
> 
> If I change it to this: (or several other syntax variations)
> 
> \<%= auto\_link(h link.send(column.name), :target =\> '\_blank') %\>
> 
> I get this:
> 
> wrong number of arguments (2 for 1)  
> Extracted source (around line #13):  
> 10: \<% for link in @links %\>  
> 11:   
> 12: \<% for column in Link.content\_columns %\>  
> 13: \<%= auto\_link(h link.send(column.name), :target =\>  
> ‘\_blank’) %\>  
> 14: \<% end %\>  
> 15: \<%= link\_to ‘Show’, :action =\> ‘show’, :id =\> link %\>  
> 16: \<%= link\_to ‘Edit’, :action =\> ‘edit’, :id =\> link %\>
> 
> I’ve looked here:  
> [http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html](http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html)
> 
> I’m pretty sure it’s probably something glaringly obvious that I’m  
> missing, but rather than bang my head incessantly on my keyboard, I  
> figured I’d save myself the qwerty imprints on my forehead and  
> ask. 🙂
> 
> Thanks,  
> Samantha
> 
> –  
> [http://www.babygeek.org](http://www.babygeek.org)

---

<div class="post-metadata">

**Author:** ![Samantha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Samantha](https://www.ruby-forum.com/u/Samantha)\
**Post date:** [March 27, 2007, 2:57am UTC](https://www.ruby-forum.com/t/actionview-texthelper-auto-link/90098/3 "2007-03-27T02:57:28Z")

</div>

Thanks, Shawn.

I tried that, but then nothing shows up except for the column headers,  
and the Show Edit Destroy links.

The URL and the other fields’ content don’t show up!

this is what I’ve got in there now:

\<%= auto\_link(h(link.send(column.name)), :target =\> ‘\_blank’) %\>

When I put in the original code that worked, but without the target =\>  
‘\_blank’ part, it shows the data…

Also, when I type " :target =\>\> ‘\_blank’)" it complains about an  
unexpected \>

Thanks!

Samantha

On 3/26/07, Shawn [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > in my database is a url. I have successfully gotten it to format in
> > 
> > 11:   
> > I’m pretty sure it’s probably something glaringly obvious that I’m
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Samantha

[http://www.babygeek.org/](http://www.babygeek.org/)

“Beware when the great God lets loose a thinker on this planet. Then  
all things are at risk.”  
–Ralph Waldo Emerson

---

<div class="post-metadata">

**Author:** ![Samantha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Samantha](https://www.ruby-forum.com/u/Samantha)\
**Post date:** [April 3, 2007, 2:13am UTC](https://www.ruby-forum.com/t/actionview-texthelper-auto-link/90098/4 "2007-04-03T02:13:04Z")

</div>

Thanks, Conrad!

I got it working over the weekend. 🙂 I needed to use the href options  
🙂

Samantha

On 4/1/07, Conrad T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Samantha wrote:
> 
> > > 
> > 
> > all things are at risk."  
> > –Ralph Waldo Emerson
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Samantha

[http://www.babygeek.org/](http://www.babygeek.org/)

“Beware when the great God lets loose a thinker on this planet. Then all  
things are at risk.”  
–Ralph Waldo Emerson

---

<div class="post-metadata">

**Author:** ![Samantha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Samantha](https://www.ruby-forum.com/u/Samantha)\
**Post date:** [April 2, 2007, 2:20am UTC](https://www.ruby-forum.com/t/actionview-texthelper-auto-link/90098/5 "2007-04-02T02:20:28Z")

</div>

Hi Samantha, please remove the extra ‘\>’. For example, it should be:

\<%= auto\_link( h( link.send( column.name ) ), :target =\> ‘\_blank’ ) %\>

Good luck,

-Conrad

Samantha wrote:

> Thanks, Shawn.
> 
> I tried that, but then nothing shows up except for the column headers,  
> and the Show Edit Destroy links.
> 
> The URL and the other fields’ content don’t show up!
> 
> this is what I’ve got in there now:
> 
> \<%= auto\_link(h(link.send(column.name)), :target =\> ‘\_blank’) %\>
> 
> When I put in the original code that worked, but without the target =\>  
> ‘\_blank’ part, it shows the data…
> 
> Also, when I type " :target =\>\> ‘\_blank’)" it complains about an  
> unexpected \>
> 
> Thanks!
> 
> Samantha
> 
> On 3/26/07, Shawn [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > > in my database is a url. I have successfully gotten it to format in
> > > 
> > > 11:   
> > > I’m pretty sure it’s probably something glaringly obvious that I’m
> > 
> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > >
> 
> –  
> Samantha
> 
> [http://www.babygeek.org/](http://www.babygeek.org/)
> 
> “Beware when the great God lets loose a thinker on this planet. Then  
> all things are at risk.”  
> –Ralph Waldo Emerson
