0

我目前在我的 Rails 应用程序中有以下链接:

<%= 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>

关于如何使用确认框将其转换为删除链接的任何想法?

4

1 回答 1

2

尝试这个。

<%= link_to "Remove #{@person.name}", @person, :confirm => 'Are you sure?', :method => :delete, :class => 'important', :class => "minimal important" %>
于 2010-10-22T20:28:29.757 回答