B
B
bobanuk2015-01-12 18:52:10
Ruby on Rails
bobanuk, 2015-01-12 18:52:10

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'

users_controller.rb
def index
  end

  def show
    @user = User.friendly.find(params[:id])
  end

user.rb
extend FriendlyId
  friendly_id :name, use: :slugged

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Burmakin, 2015-01-12
@bobanuk

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 question

Ask a Question

731 491 924 answers to any question