To show User's profile I used their id. In controller:
@user = User.find(params[:id])
get ':id' => 'users#show'
But now I try new way with username:
get ':username' => 'users#show' #route @user = User.find_by(username: params[:username]) #controller
And when I go to user's profile with
/username I see error:
undefined method posts. In controller I get user's posts. But now it doesn't works. Please tell me why? And I have one more question. When I go to
/posts or something else, my app thinks, that I go to uset's page. How to fix it? And what to do, if user sign up with, for example, username: "users"?