내 레일 애플리케이션에 추종자를 추가하려고합니다. 내 서버 시작 rails s
을 실행할 때 다음과 같은 오류를보고하고있다 :잘못된 경로 이름 (이미 사용 중) : 'user'
Invalid route name, already in use: 'user' (ArgumentError)
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
경로를
Rails.application.routes.draw do
devise_for :users
resources :users do
member do
get :following, :followers
end
end
resources :relationships, only: [:create, :destroy]
resources :posts do
member do
post '/like' => 'posts#like'
end
end
get ':username' => 'users#show', as: 'user'
root 'home#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
내가 추가 한 알고 도움이 될 수
:
resources :users do
member do
get :following, :followers
end
end
resources :relationships, only: [:create, :destroy]
위의 내용을 추가하기 전에 레일 응용 프로그램이 작동했습니다.
나는 아마도 이것이 간단한 수정 일 것이라고 확신하지만 레일을 처음 사용합니다. 저는 한 시간 이상 길 찾기와 온라인 검색을 해왔으며 문제를 이해하고 해결하려고 노력했습니다. 더 많은 지식을 가진 사람이 나를 올바른 방향으로 안내 할 수 있기를 바랍니다.
감사합니다 : 당신이 중 하나
참조, 특정 접두사처럼 아래 을 고안를 넣을 수 있습니다! 그게 내 문제를 해결해 줬어. 나는 심지어 그것을 알아 차리지 못했다. – GVS
진심으로 환영합니다. –