I'm pretty new at rails, so forgive me if I'm overlooking simple things or the rails way. My objective is to completely replace URLs of the form
/users/1
with
/username
for all purposes. (I think exposing IDs scaffolding publicly is like walking around with a bone sticking out of your arm.) But implementing seems a little more complicated than I expected. This seems to change the entire way rails indexes and looks up users, rather than just substituting a lookup method.
Although I've kind of gotten this to function using the to_param
override in my user.rb
file, I've read this means I'll have indexing problems down the road when using params([:username])
, and I'm not sure how it will impact my
(a) session model at new user creation, and
(b) @User usage in the user/show.html.erb file.
So, I've either consulted the following pages (or asked the questions):
- Ruby on rails routing matching username
- customize rails url with username
- Routing in Rails making the Username an URL:
- routing error with :username in url
- Correct routing for short url by username in Rails
- rails3, clean url, friendly_id, sessions
The major issues I'd like to understand from this question:
- What functionality do I lose by transitioning to this? That is, what things currently "just work" in rails that I'll have to address and rewrite if I pursue this replacement?
- As a practice, is this something better to replace with friendly_id? My concern here is that creating a slug column in my DB identical to the username seems a little non-DRY and makes me uncomfortable, and I'd rather avoid dependencies on external gems where possible.
- What does my users#show need to look like?