我目前在我的Rails应用程序中有以下link_to:
<%= link_to 'Remove this Person', @person, :confirm => 'Are you sure?', :method => :delete, :class => 'important', :class => "minimal important" %>
我想添加此人的姓名代替“此人”作为链接。
我似乎无法做到:
<%= link_to 'Remove <%= @person.name %>', @person, :confirm => 'Are you sure?', :method => :delete, :class => 'important', :class => "minimal important" %>
我在网上看过这个例子:
<%= 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>
有关如何将其转换为删除链接的任何想法,请使用确认框?
答案 0 :(得分:2)
试试这个。
<%= link_to "Remove #{@person.name}", @person, :confirm => 'Are you sure?', :method => :delete, :class => 'important', :class => "minimal important" %>