# Rails 3 - Using link\_to but adding a # for AJAX Deep Linking

**URL:** <https://www.ruby-forum.com/t/rails-3-using-link-to-but-adding-a-for-ajax-deep-linking/195953>\
**Category:** Rails\
**Created:** [October 3, 2010, 10:14pm UTC](https://www.ruby-forum.com/t/rails-3-using-link-to-but-adding-a-for-ajax-deep-linking/195953 "2010-10-03T22:14:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [October 3, 2010, 10:14pm UTC](https://www.ruby-forum.com/t/rails-3-using-link-to-but-adding-a-for-ajax-deep-linking/195953/1 "2010-10-03T22:14:08Z")

</div>

Hello,

Currently my links in Rails are using link\_to as follows:

```
<%= link_to project.name, project %>

```

Which makes something like: `<a href="/projects/1">Project 1</a>`

I’m working to implement an AJAX app with deep linking so instead of  
the above, I want the output to be (with a #): `<a href="#/projects/ 1">Project 1</a>`

Is there a way to get this to work with link\_to? Or do I need some  
type of custom helper so I can use something like `link_deep_to`

Thanks

---

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [October 4, 2010, 9:57am UTC](https://www.ruby-forum.com/t/rails-3-using-link-to-but-adding-a-for-ajax-deep-linking/195953/2 "2010-10-04T09:57:28Z")

</div>

Hi,

Try with  
\<%= link\_to project.name, “#” + project %\>  
or  
\<%= link\_to project.name, “#” + projects\_path %\>

Please let me know if it doesn’t work out.

Thanks!  
Butu

---

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [October 4, 2010, 5:51pm UTC](https://www.ruby-forum.com/t/rails-3-using-link-to-but-adding-a-for-ajax-deep-linking/195953/3 "2010-10-04T17:51:35Z")

</div>

thanks!

---

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [October 4, 2010, 7:53pm UTC](https://www.ruby-forum.com/t/rails-3-using-link-to-but-adding-a-for-ajax-deep-linking/195953/4 "2010-10-04T19:53:55Z")

</div>

Very nice! thank you both

---

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [October 4, 2010, 6:23pm UTC](https://www.ruby-forum.com/t/rails-3-using-link-to-but-adding-a-for-ajax-deep-linking/195953/5 "2010-10-04T18:23:52Z")

</div>

Butu wrote:

> Hi,
> 
> Try with  
> \<%= link\_to project.name, “#” + project %\>  
> or  
> \<%= link\_to project.name, “#” + projects\_path %\>
> 
> Please let me know if it doesn’t work out.

Minor syntax point: “##{project}” is actually more efficient than “#” +  
project , since it generates fewer String objects.

> Thanks!  
> Butu

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
