【问题标题】:Add a value to a delete link in Rails?向 Rails 中的删除链接添加值?
【发布时间】:2011-04-29 09:03:55
【问题描述】:

我目前在我的 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>

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

【问题讨论】:

    标签: ruby-on-rails url hyperlink link-to


    【解决方案1】:

    试试这个。

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

    【讨论】:

    • 我认为将其转换为删除是不可能的,因为删除链接确实比其他链接更难
    猜你喜欢
    • 1970-01-01
    • 2015-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多