Reputation: 470
I am developing with Ruby on Rails, want to know whether there is an efficient way to find a name matches a hashtag.
Input: #annrobinson
if there is a record name "Ann Robinson"
, it matches
if there are other records, like "Ann Robin Son"
, "Annro Bin son"
, they fulfill the requirement too.
Many thanks!
Upvotes: 1
Views: 249
Reputation: 5734
Suppose User is your model. Then you can get it by
User.where("CONCAT('#',LOWER(REPLACE(name, ' ', ''))) = ?", '#annrobinson')
Upvotes: 1