如何将数据传递到<a> tag like link_to rails

时间:2017-07-18 10:51:23

标签: html ruby-on-rails ruby

I'm trying to transform this ruby link_to method into a classic tag. And before i'd use to pass some value (idz) into the parse after the link tag.

Is it possible to do the same with tags. Is because I need this value (idz) to run my controller method

Before :

<%= link_to rem_admin_group_path(group, idz: admin.id), method: :patch, remote: true do %>
  <div class="btn btn-danger pull-right"style='margin-left: 10px;'>
    <i class="fa fa-close" aria-hidden="true" ></i>
  </div>
<% end %>

After (without the value idz):

<a href="groups/<%=group.id%>/rem_admin",  data-method="patch" data-remote="true">
  <div class="btn btn-danger pull-right"style='margin-left: 10px;'>
    <i class="fa fa-close" aria-hidden="true" ></i>
  </div>
</a>

1 个答案:

答案 0 :(得分:1)

您可以尝试这样的事情

<a href="groups/<%=group.id%>/rem_admin?idz=<%=admin.id%>",  data-method="patch" data-remote="true">
  <div class="btn btn-danger pull-right"style='margin-left: 10px;'>
    <i class="fa fa-close" aria-hidden="true" ></i>
  </div>
</a>
相关问题