Answer the question
In order to leave comments, you need to log in
How to make short path localhost:3000/danil instead of localhost:3000/users/danil Using friendly_id gem and Devise?
Hello, I need help, I can't figure out how to route. How to make short path localhost:3000/danil instead of localhost:3000/users/danil Using friendly_id gem and Devise.
routes.rb
devise_for :users
resources :users
root 'users#index'
def index
end
def show
@user = User.friendly.find(params[:id])
end
extend FriendlyId
friendly_id :name, use: :slugged
Answer the question
In order to leave comments, you need to log in
Sergei Krasnodemsky suggested not bad, but this is not a rails way. To get rid of the model name in the URL for a RESTful resource, you must specify the "null" path:resources :users, path: ''
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question