rubylink-to-function

How to display current username as a Link in RUBY?


<%= link_to ' ', user_path(current_user) %>

How do I make it so <% current user %> displays the current user as a link. Because in ruby whatever goes inside Link to is written as a string and not displayed as Ruby's answer.


Solution

  • Use below code replace name with field that stores user's name

    <%= link_to current_user.name, user_path(current_user) %>