I'm listing a set of data (for simplicity sake, just the identity column) of a particular database table table as follows:
<%= @fields.select{|field| field.model=="PreferredOffering"}.each do |field| %>
<%= field.id %>
<br/>
<% end %>
As you may have gathered from above, I'm using the combination of select
and each
to iterate ONLY through rows whose column model
contains the string PreferredOffering
.
My expectation was that I would see a nice ordered list of numbers and indeed I do. My confusion is that I ALSO see the entire @fields
array coughed all over the page, below the list of numbers. (See below html excerpt)
106
<br/>
107
<br/>
108
<br/>
109
<br/>
110
<br/>
111
<br/>
112
<br/>
[#<PreferredOfferingField id: 5, field_heading: "Anti-dilution provisions- Typical Weighted Average", category: "Anti-Dilution", intra_cat_order: 1, model: "P
My guess is that I'm doing something funny with select
as I'm not really familiar with its usage.
Any ideas on how to remedy this would be received gratefully; thanks in advance.