Could I make Tags case insensitive

(Lorne) #1

To use it in a url ( would ideally be able to match this with the tag ‘Cool’ via Article.with_any_tags(params[:tag])

Currently this doesn’t match. It would have to be

This could just be me being slightly OCD, but I thought it was worth posting!

(Aaron Russell) #2

Currently this is not possible, but I think this is a good suggestion. Not sure how best to approach though.

The easy way would be to simply lowercase all tags before they get saved in the database, but this dictates a tagging style to all users. Some people might prefer to have capitalisation for various reasons.

Alternatively we change the database queries to be case insensitive. The SQL involved queries arrays in a json object, and to be honest I’m not entirely sure how you’d map the values you’re querying to lowercase. I’m sure it’s possible but with some relatively ugly SQL gymnastics involved (the sql is already quite ugly). In case you’re interested the code is here:

It might be worth trying to add a Article.with_any_tags_i() method to your app to see if you can achieve this. If you can I’d love to see the code and maybe it can be merged in.

(Lorne) #3

Awesome, thanks for the reply! Will have a nosy around when I get a chance, see what I can come up with!