edenisn
edenisn

Reputation: 155

DRY link_to for current_user

How to DRY this code with helper?

<% if current_user %>
  <%= link_to "All images", images_path %>
<% end %>

Thanks

Upvotes: 3

Views: 76

Answers (1)

Mori
Mori

Reputation: 27789

You can use the link_to_if helper:

<%= link_to_if current_user, 'All Images', images_path %>

Upvotes: 4

Related Questions