i want to use a common partial to render a listing page and its going good expect i am facing a problem to generate dynamic link_to for :edit and :delete action which is common.
so i have @menu and @picture model in two different views rendering the same common partial (which i created).
this is my common partial.
shared/_index_common_grid.html.erb
<% pictures.each do |picture| %>
<div class="col-sm-4 pull-left">
<div class="thumbnail">
<div class="caption">
<h4><%= picture.title.capitalize%></h4>
<p class="text-muted">
<!--THIS IS WHERE I WANT TO HANDLE DYNAMIC GENERATION OF LINK_TO FOR @picture and @menu models -->
<%= link_to "Edit", [:edit, current_user,@request,@shop,picture]%>
| <%= link_to "Delete", [current_user,@request,@shop,picture],:data=>{:confirm=>"Are you sure ?"}%>
| <span class="pull-right"><%= show_formatted_date(picture.created_at)%></span>
</p>
</div>
</div>
</div>
<%end%>
this is my one view using above common partial,there is one more similar to this except i pass different model.
##my view page --------pictures/index
<%unless @pictures.blank?%>
<%= render partial: "shared/index_common_grid", locals: {pictures: @pictures}%>
<%end%>
I dont want to go with switch case in application_helper which can be done easily.
picturesandmenus? Just the issue is link for edit and delete for pictures and menus will be different? What are the requiredparamsfor the menu? And are you on rails 3 or rails 4?menus? Means there are options likeurl_forin rails which might help you. But that depends on the parameters required for each of them.