I am trying to get custom routes based on the username rather than the ID. I have it working to get to the show page of the user but I am also trying to nest the resources so that I can see his posts and comments using the same syntax.
Example:
Works… “mysite.com/users/username/”
Does not work… “mysite.com/users/username/posts/”
routes.rb
...
# Users with the Username...
match 'users/:username' => "users#show" do
get :posts
get :comments
end
# Users with the ID...
resources :users do
get :posts
get :comments
end
...
Perhaps you can use the to_param method and update your nested routes/resources:
routes.rb:
user.rb
..for finds in the UserController:
(or any variation of finding by the username criteria)