Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails link_to syntax in order to add some inner html

I have this code to generate a "unfollow" button via the 'link_to' function:

<%= link_to "Non seguire più", user_user_relationship_path(id:@relationship.id), remote: true, id: "follow_#{@user.id}", class:"btn btn-small btn-danger", method: :delete %>

I would like to know ho to use the "do..end" syntax with all those arguments.. Thanks!

like image 295
Ciampo Avatar asked Aug 29 '12 22:08

Ciampo


1 Answers

You just skip the first parameter, can wrap the rest in parens, and then add the do/end.

<%= link_to(user_user_relationship_path(id:@relationship.id), remote: true, id: "follow_#{@user.id}", class:"btn btn-small btn-danger", method: :delete) do %>
  <!-- your button html here -->
<% end %>
like image 197
deefour Avatar answered Sep 21 '22 17:09

deefour