Rails 3 - Using link_to but adding a # for AJAX Deep Linking

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

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

thanks!

Very nice! thank you both

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
[email protected]