Jen Lijó Jen Lijó - 6 months ago 79
Ruby Question

Insert code inside string

I'm new to RoR. I'm trying to print the string of the current user name logged in inside the string 'Logout' to personalise the message, but I can only get a print of the code...

<% if user_signed_in? %>
<%= link_to('Log out #{current_user.first_name}', destroy_user_session_path, :method => :delete) %>

Any help would be appreciated!

Thank you.


Use double quotes when you have to interpolate

<%= link_to("Log out #{current_user.first_name}", destroy_user_session_path, :method => :delete) %>