开发者

Add a value to a delete link in Rails?

开发者 https://www.devze.com 2023-01-21 04:55 出处:网络
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\', :c

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" %>
0

精彩评论

暂无评论...
验证码 换一张
取 消