Rendering a nested attribute

I have a report model which accepts nested attributes for executive model.

class Report < ApplicationRecord
  has_many :executives

  accepts_nested_attributes_for :executives, reject_if: :all_blank,  allow_destroy: true

end

When I render these attributes on my show page:

<%= @report.executives.each do |executive| %>
            <tr>
                 <td><%= executive.project_name %></td>
                  <td><%= executive.project_number %></td>
                  <td><%= executive.potential_impact %></td>
                  <td><%= executive.date %></td>
              </tr>   
  <% end %>             

It also displays an array of all the other created attributes together with their timestamps, which I don’t want rendered on the show page.

How do I get rid of this?

Try removing the = from <%= @report.executives.each do |executive| %>.

Make it <% @report.executives.each do |executive| %> instead.

1 Like

So this is computer programming language or what,? If you can understand all these then I’m sure you people can easily write and speak Arabic oo. What a language, you are doing well. It is your field so I know you are good at it. Lemme see of I can also learn from you guys