Rails edit_polymorphic_path

This handy function comes in use when you don’t know that object type you want to edit, I used has_many_polymorphs to pull many objects related to my user object, here is the views code

<% @user.entities.each do |e| %>
<tr>
<td><%=h e.info.nameĀ  %>
<td><%= link_to 'Show', e %></td>
<td><%= link_to 'Edit', edit_polymorphic_path(e) %></td>
<td><%= link_to 'Destroy', e, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>

Leave a comment