You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ContentfulModel::Base doesn't provide a #hash method, so model instances cannot be effectively used as keys in Hashes, or easily filtered for duplicates.
For example, I have a Requirement model which has_oneCategory. After loading my requirements, I group them by category:
This throws up two problems, both arising from the lack of #hash:
Duplicate requirements from the two queries are different objects, and since they inherit the default implementation of #hash, they're not filtered out by #uniq.
Any category that was present in both sets of results ends up as two different keys in the resulting Hash, again because they are different objects.
ContentfulModel::Base
doesn't provide a#hash
method, so model instances cannot be effectively used as keys in Hashes, or easily filtered for duplicates.For example, I have a
Requirement
model whichhas_one
Category
. After loading my requirements, I group them by category:For the results of a single query, this works fine. However, sometimes I want to combine the results of two queries, to simulate a logical
OR
:This throws up two problems, both arising from the lack of
#hash
:#hash
, they're not filtered out by#uniq
.Possible solutions
In my app, I added
#hash
and#eql?
methods based closely on ActiveRecord's implementation:The text was updated successfully, but these errors were encountered: