I'm stuck again.
I have this code in my /views/
<% if DistributionSheet.find(:all, :conditions => ["lifecycle_state = ?","closed"]).last %>
<% @Specimen_ids.each do |ds| %>
<th><%= ds.id %></th>
<% end %>
</tr>
<tr>
<% @all_results.each do |result| %>
<td><%= result.distribution_sheet_id %></td><td><%= result.lab_id %></td><td><%= result.kit %></td><td><%= result.batch_number %></td><td><%= result.cutoff %></td>
<% @Specimen_results.each do |sr| %>
<td><%= sr.result_user %></td>
<% end %>
</tr>
<% end %>
<%- end -%>
</tr>
In my controller I have:
def first
@Specimen_ids = Specimen.find(:all, :order => 'distribution_sheet_id DESC', :limit => 10)
@all_results = Result.find(:all, :order => 'distribution_sheet_id DESC', :limit => 1)
@Specimen_results = SpecimenResult.find(:all, :order => 'id DESC', :limit => 10)
end
end
What I want is to say only if the LAST DistributionSheet is 'closed' then output the data detailed above ONLY for that closed DistributionSheet.
The above code does output the data, but for all the DistributionSheet. The first if statememnt doesnt seem to be doing anything. I hope I have explained this. If you like more explanation then please tell me. Many thanks in advance.