0

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.

1
  • 2
    use double quotes for the string Commented Sep 15, 2016 at 11:31

2 Answers 2

2

Use double quotes when you have to interpolate

<%= link_to("Log out #{current_user.first_name}", destroy_user_session_path, :method => :delete) %>
Sign up to request clarification or add additional context in comments.

4 Comments

(Sure, it's a dupe, but that's not a valid reason to downvote a correct answer.)
Thank you! This worked. I'm not very familiar with ROR terms yet (string interpolation) to formulate the exact question. +++
@DaveNewton what was the comment about. I didn't get that
Someone downvoted your answer, which was improper behavior.
1

try this,

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

you can't use interpolation with single-quoted string. Instead you can use double quotes.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.