mercredi 1 février 2017

change routes URL from a random :id to :username in rails

I want to change my routes.rb file in a way so that it changes my current urls

 localhost:3000/amitian/1

to localhost:3000/username

I will provide my routes.rb file for reference

  Rails.application.routes.draw do

 devise_for :amitians

 root 'home#index'
 resources :amitians do
 member do
 get :following, :followers
 end
end
 resources :confessions do
member do
    get 'like' , to: 'confessions#upvote'
    get 'dislike' , to: 'confessions#downvote'
    end
    resources :confessioncomments
  end
    resources :relationships, only: [:create, :destroy]

 end

Aucun commentaire:

Enregistrer un commentaire