Reputation: 810
Assuming there is a community who has both "apple" and "APPLE" tags.
Then if I execute this with the param "apple"
@communities = Community.joins(taggings: :tag).where(tags: { name: params[:tag] })
In result page, 2 sets of the same community come appears.
It's probably because it's fetching with the params[:tag] for both upper case and lower case.
How can I strict this and make it not like
search?
I want case-sensitive and complete match.
Upvotes: 0
Views: 357
Reputation: 10137
Try enclosing attribute name in binary.
@communities = Community.joins(taggings: :tag).where(['binary(tags.name) = ?', params[:tag]])
Upvotes: 4