app/views/tasks/content/by_nomenclature/index.html.erb
<h2> Content by nomenclature </h2>
<div>
<p> Select a topic to display all Content of that type for the OTUs of the species in this project.
<%= tag.span('Content is restricted to those species that have family names.', class: %w{feedback feedback-warning feedback-thin}) -%>
</p>
</div>
<%= form_tag(content_by_nomenclature_task_path, method: :get) do %>
<%= tag.span('Select topic') %>
<%= select_tag(:topic_id, options_from_collection_for_select(Topic.where(project_id: sessions_current_project_id).order(:name), 'id', 'name')) %>
<%= tag.input(type: :submit, class: :button, value: 'Set') -%>
<% end %>
<% if !@topic.nil? %>
<% @rowcount = 1 %>
<h2>Topic: <%= @topic.name -%> </h2>
<table>
<tr>
<td> Row</td>
<td> Order </td>
<td> Family </td>
<td> Subfamily </td>
<td> Tribe </td>
<td> Name </td>
<td> Author year </td>
<td> <%= @topic.name -%> </td>
</tr>
<% @taxon_names.find_each do |n| %>
<% a = n.ancestor_hash %>
<% if !a['family'].blank? %> <!-- TODO: restrict query to those with famil/y names -->
<tr>
<td> <%= @rowcount -%> </td>
<td> <%= a['order'] -%> </td>
<td> <%= a['family'] -%> </td>
<td> <%= a['subfamily'] -%> </td>
<td> <%= a['tribe'] -%> </td>
<td> <%= n.cached -%> </td>
<td> <%= n.cached_author_year -%> </td>
<td> <%= Content.where(project_id: sessions_current_project_id).find_by(topic: @topic, otu: n.otus)&.text %> </td>
</tr>
<% @rowcount = @rowcount + 1 %>
<% end %>
<% end %>
</table>
<% end %>