Ruby on Rails
Monday, May 4, 2015
After following so many Stackoverflow and other related posts I was able to render modal (_show.html.erb) from inside index.html.erb. But the problem the parameter I'm sending is showing same id and other details for all show buttons.
-- For instance if there are 5 different members listed in index.html.erb, when I press the corresponding show button, the same id and other details as the first member is showing for all members.
index.html.erb
<tbody>
<% @designation_dicts.each do |designation_dict| %>
<tr>
<td><%= designation_dict.desig_code %></td>
<td><%= designation_dict.designation %></td>
<td><%= render :partial => "show", :locals => {:designation_dict => designation_dict} %></td>
<td><%= link_to 'Show', "#myModal", "data-toggle" => "modal", :class => 'btn btn-default' %></td>
<td><%= link_to 'Edit', edit_designation_dict_path(designation_dict), :class => 'btn btn-default' %> </td>
<td><%= link_to 'Destroy', designation_dict, method: :delete, data: { confirm: 'Are you sure?' } , :style => 'color:#FFFFFF', :class => 'btn btn-danger' %></td>
</tr>
<% end %>
</tbody>
Part of the modal (_show.html.erb)
<div class="modal-body"> <div class="table-responsive">
<table class="table table-striped table-show">
<tr>
<th>
<strong>Designation code:</strong>
</th>
<td>
<%= designation_dict.desig_code %>
</td>
</tr>
<tr>
<th>
<strong>Designation description:</strong>
</th>
<td>
<%= designation_dict.designation %>
</td>
</tr>
</table>
</div>
Thank you
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/289b6e47-6880-44da-9f05-7f1d0f1b3feb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment