I want to let users have links to their profiles using their registered usernames.
I store their username exactly how they give it.
I set up my routes to match /:name and then used find_by_name to get it. The problem I have is when you type in example.com/username it doesn’t work the name: Username. (Note the uppercase/lowercase difference)
So my question is how can I ignore case in urls?
You can store the
usernamedowncased along with adisplay_namewhich is in the format they gave it to you. Then, downcase any input and match it withusernameand only usedisplay_namefor, well, display 🙂If you wanted, you could even redirect to
/DisPlAyNamefrom/usernameafter you look up the record.