I'm trying to open a link in another tab
I have this
<%= link_to 'Home', root_path if current_user %>
And I have tried this
<%= link_to 'Home', root_path if current_user, target: :_blank %>
But nothing works
I'm trying to open a link in another tab
I have this
<%= link_to 'Home', root_path if current_user %>
And I have tried this
<%= link_to 'Home', root_path if current_user, target: :_blank %>
But nothing works
Try like below (place the if condition in last ) :-
<%= link_to 'Home', root_path, target: :_blank if current_user %>
Signature:-
link_to(body, url, html_options = {})
To open a link in another tab we have to use target: :_blank option of html.
For more see this reference :- http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to