In my app I have 3 tables Patient, Department and Consultant. In
patient table I have passed foreign key of other other two tables.
Now, In my index view of patient I'm able to fetch data of department
table with each loop :

<tbody>
  <% @departments.each do |d| %>
    <% @patient = Patient.where(department_id: d.id) %>
      <% @patient.each do |patient| %>
        <tr>
          <td><%= patient.patient_name %></td>
          <td><%= patient.patient_age %></td>
          <td><%= d.name %></td>
    <% end %>
  <% end %>
 </tbody>

Now my question how should I fetch data from consultant table using
each loop, same way as I did for department table in above code. I
need little guidance on this. Thanks in advance.

-- 
Cheers!

Deepak Kumar Sharma
Guru Nanak Dev Engineering College
India!

Blog: http://deekysharma.wordpress.com

-- 
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/CALDHwN6G%2BZ0bSC6bKL1e%3DJmFqn6DJyNcgjrF0AvnjhyLanBK-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to