dimanche 12 juillet 2020

How to use find_by_username with case_sensitive: false?

How to use find_by_username with case_sensitive: false?

I explain my issue. I have this script to take the username tagged (after @) and to check if it is a "existing user" or not.

text.gsub! (/@(\S+)/) do |match|
  user = User.find_by_username($1)
    if
    else
    end
  end

In this way if the text is @Mike and the user signed is Mike, it is ok. BUT if the text is @mike and the user signed is Mike, it doesn't work.

Hot to add a case_sensitive false in find_by_username?

Aucun commentaire:

Enregistrer un commentaire