I'm adding a confirmation dialog to a delete operation in my rails tutorial, and I want to include some text from the object to be deleted. So I tried this:
<%= link_to 'Delete', article_path(article), method: :delete, data: { confirm: 'Really delete blog "#{article.title}"?' } %>
The substitution does not happen: the resulting dialog says Really delete blog "#{article.title}"?
.
I've changed it to use format strings and it's working fine:
<%= link_to 'Delete', article_path(article), method: :delete, data: { confirm: 'Really delete blog "%s"?' % article.title } %>
The substitution happens: the resulting dialog says Really delete blog "Of cabbages and kings"?
What do I change to make the more-readable "#{article.title}" work for me? What's the difference?