<td><%= render :partial => "show", :locals => {:designation_dict => 
designation_dict} %></td>

In your locals you are sending designation_dict.  Is there something in 
designation_dict that is unique to all the records?  Hopefully an id...

Do you have that unique field, let's call it dd_id?

Now this is going to seem to be Ad nauseam, and Mr Law refers to 
id="MyModal", which I do not see, yet he is entirely correct.  What I 
understand is that you have an each statement that is iteratively 
loading...A partial, and numerous link_to

For later, however you need it as params or js elements, each of these 
elements must contain -- at some required element level -- a unique html id.

Look at the changes I made to your partial:

<div class="modal-body" id="modal-body_<%= designation_dict.dd_id %>">
<div class="table-responsive" id="table-responsive_<%= 
designation_dict.dd_id %>">
<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>

Do you see now how you are generating unique html ids?

<td><%= link_to 'Show', "data-toggle" => "modal", :class => 'btn 
btn-default', :id => designation_dict.dd_id %></td>


Once you make these changes, and then View Page Source, you will see that a 
unique id has been generated.... Folks will probably offer more elegance 
solutions, but the spirit remains the same.

Hope this helps...

Liz

On Monday, May 4, 2015 at 10:47:06 AM UTC-4, Padmahas Bn wrote:
>
> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/17d2a1b5-f7ed-40b7-acf0-daf0a70340a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to