I currently have the following link_to in my Rails application:
<%= link_to 'Remove this Person', @person, :confirm => 'Are you sure?', :method => :delete, :class => 'important', :class => "minimal important" %>
I would like to add the person's name in place of the "this person" for the link.
I don't appear to be able to do:
<%= link_to 'Remove <%= @person.name %>', @person, :confirm => 'Are you sure?', :method => :delete, :class => 'important开发者_JAVA技巧', :class => "minimal important" %>
I have seen this example online:
<%= link_to(@profile) do %>
<strong><%= @profile.name %></strong> -- <span>Check it out!</span>
<% end %>
# => <a href="/profiles/1">
<strong>David</strong> -- <span>Check it out!</span>
</a>
Any ideas on how to convert that into a delete link, with the confirmation box?
Try this.
<%= link_to "Remove #{@person.name}", @person, :confirm => 'Are you sure?', :method => :delete, :class => 'important', :class => "minimal important" %>
精彩评论