How do I create DESTROY link with Slim?

0

I'm starting with Rails, and I'm not able to create a link to delete a "post" from the site.

Follow the links new and edit

p.btn = link_to "Editar informações", edit_property_path(@property) if current_user == @property.user

p.btn = link_to "Editar imagens", new_property_media_content_path(@property) if current_user == @property.user

p.btn = link_to "Excluir
", property_path(@property) if current_user == @property.user, :confirm => 'Are you sure?', :method => :delete

Show error:

  

syntax error, unexpected ',', expecting ')'

    
asked by anonymous 04.12.2014 / 21:00

1 answer

0

Well, it's wrong the way you're using the check inside the Excluir link. Remember that link_to is a method so what you send to it are the parameters, you should not put the check there to show the link or not.

Here is your refactored example: if current_user == @property.user p.btn= link_to "Editar informações", edit_property_path(@property) p.btn= link_to "Editar imagens", new_property_media_content_path(@property) p.btn= link_to 'Excluir', property_path(@property), :method => :delete, :data => {:confirm => 'Are you sure?'}

    
10.12.2014 / 14:43