AnApprentice
AnApprentice

Reputation: 110940

rails 3 link_to with ONLY_path = false

This doesn't give the full URL, which breaks as it's in a mailer

<%= link_to @conversation.title, conversations_path %>

This gives me the full URL, which is good:

<%= conversations_url(:only_path => false) %>

How do I get the best of both worlds? I want to link_to but have the full path?

Thanks

Upvotes: 3

Views: 4649

Answers (2)

Oluf Nielsen
Oluf Nielsen

Reputation: 779

Without testing this.. Have you tried this?

<% conversations_url(:only_path => false) do %>   
  @conversation.title 
<% end &>

Upvotes: 6

Stefan Pettersson
Stefan Pettersson

Reputation: 453

Thanks Oluf, ran into your answer when I was trying to fix a similiar problem.

The link may be rewritten into:

<%= link_to( @conversation.title, conversations_url( :only_path => false)) %>

Upvotes: 4

Related Questions