Rails 3 link_to with ONLY_path = false

This does not give a complete URL that breaks down like in a mailbox

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

This gives me the full URL, which is good:

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

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

thank

+3
source share
2 answers

Without testing this .. Have you tried this?

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

Thanks Oluf, came across your answer when I tried to fix a similar problem.

The link can be rewritten to:

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

Source: https://habr.com/ru/post/1774874/


All Articles