Jen Lijó Jen Lijó - 1 year ago 157
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.

Answer Source

Use double quotes when you have to interpolate

<%= link_to("Log out #{current_user.first_name}", destroy_user_session_path, :method => :delete) %>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download