<% @sp_references.each do |sp_ref| %>
<% sp_ref.all_references.each_with_index do |tax_ref, i| %>
<%if (tax_ref.reference.uniq) && (tax_ref.reference !~ /emend$/i) %>
<%= tax_ref.reference %>
<%end%>
<%end%>
<%end%>
This ‘uniq’ option to get distinct elements in tax_ref.reference is not working. It shows “undefined method `uniq’ for #<String:”. Kindly help me this regard to get the distinct elements from array using each in rails.
This 'uniq' option to get distinct elements in tax_ref.reference is not
working. It shows "undefined method `uniq' for #<String:". Kindly help me
this regard to get the distinct elements from array using each in rails.
Sounds like tax_ref.refrence is a string, not an array so calling uniq
on it doesn't make any sense.
I need the results have to print without duplicates. This gives the results
with duplicates.
<snip>
and
<snip>
presents same results with duplicates. Please about your suggestion.
I'm having trouble seeing where you're even trying to explain what you
have, and what you want....
Does this give what you're after? :
<%= @sp_references.map(&:all_references).flatten.map(&:reference).uniq.delete_if{|ref|
ref=~ /emend$/i}.join("<br/>") %>
To be honest, I'm just stabbing in the dark, because you've not
explained anything about what these objects are made of or what actual
end result you want to achieve... some pseudo-code would help...