Ruby on Rails Report


This is my output.
You can see ‘Mr.Sandun Gamage’ should come into contact person 2 column.but now it comes in contact person1(3rd). Please help to get it.
Here is my code belong to those columns.

- if Organization.find_by_id(db.id).organization_contact_persons.contact_persons1.present?
- Organization.find_by_id(db.id).organization_contact_persons.contact_persons1.each_with_index do |organization_contact_person, index|
- if index < 3
%td= organization_contact_person.full_name
- else
- 3.times.each do |e|
%td

- if Organization.find_by_id(db.id).organization_contact_persons.contact_persons2.any?
- Organization.find_by_id(db.id).organization_contact_persons.contact_persons2.each_with_index do |organization_contact_person, index|
- if index < 3
%td= organization_contact_person.full_name

- else
- 3.times.each do |e|
%td

Having a little difficulty understanding what you’re trying to do here, but I think your issue is that you need to fill 3 columns for contact person 1 regardless of whether you have 3 names or not. In this case, you have 2 names, so if I understand what’s going on correctly, you’re not getting a %td for Contact Person1 (3rd).