2010-10-22 76 views
0

目前,我有以下的link_to在我的Rails应用程序:将值添加到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> 

如何将其转换成一个删除链接任何想法,与确认框?

回答

2

试试这个。

<%= link_to "Remove #{@person.name}", @person, :confirm => 'Are you sure?', :method => :delete, :class => 'important', :class => "minimal important" %> 
+2

字符串上的双引号,对吧?或者它不会被解析? – pjmorse 2010-10-22 20:29:50

+0

它必须是双引号。 – mway 2010-10-22 20:32:15

+0

我想转换,删除是不可能的,因为删除链接是真的比别人更难 – Bohdan 2010-10-22 20:33:26