views:

24

answers:

1

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', :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?

+2  A: 

Try this.

<%= link_to "Remove #{@person.name}", @person, :confirm => 'Are you sure?', :method => :delete, :class => 'important', :class => "minimal important" %>
krunal shah
Double quotes on the string, right? Or it won't be parsed?
pjmorse
It must be double quotes.
mway
I suppose that convert that to delete isn't possible because delete link is really more difficult than others
Bohdan Pohorilets
@pjmorse,@mway Thanks
krunal shah
Perfect, worked a treat. Thanks!
dannymcc