I have a collection of Fabrics each Fabric has many colours.
My DB association Fabric has_many Colours through Fabric_colours
I am using solr to index my Fabrics, so structuring complex SQL queries is not possible.
The join model Fabric_colours, holds fabric_id colour_id percentage
The Colours model holds the hex value of each Colour.
I would like to display in my view,
each colour present in a said fabric, the percentage in which said Colour is present
My view is loading dozens of fabrics at a time and I do not want to perform additional queries to get this information. It was my understanding that Solr has pulled all of the associated table’s data into a single ‘document’ so this should not be necessary.
At present in my _fabric partial i have the following code showing the colours present in that fabric.
<% fabric.colours.each do |c| %>
<%= c.hex %>
<% end%>
how would i call the the specific join table entry linking the fabric, and that specific colour, to extract the percentage?