0
몇 가지 질문이있는 것 같지만 모든 내용을 읽었지만 도움이되지 않습니다.중첩 리소스에서 작동하도록 link_to를 가져올 수 없습니다.
= link_to "towns attractions", towns_attractions(town.id)
내가 town.id
상의 inspect
짓을하고 id
가 정확한지 :
나는 views/towns/index.html.haml
이 있습니다. 내가
http://127.0.0.1:3000/towns
에 갈 수 있으며 (이 나누기 때문에) 내 link_to
을 찍을 때 내가
http://127.0.0.1:3000/towns/1/attractions
에 갈 수 있기 때문에
내 노선 좋아 보인다.
그러나, 나는 index.html.haml
이 오류가 발생합니다 :
undefined method `towns_attractions'
나는 행운으로 복수화의 모든 조합을 시도했다!
내 경로 :
resources :towns do
resources :attractions
end
레이크 경로 :
town_attractions GET /towns/:town_id/attractions(.:format) attractions#index
POST /towns/:town_id/attractions(.:format) attractions#create
new_town_attraction GET /towns/:town_id/attractions/new(.:format) attractions#new
towns GET /towns(.:format) towns#index
POST /towns(.:format) towns#create
new_town GET /towns/new(.:format) towns#new
edit_town GET /towns/:id/edit(.:format) towns#edit
town GET /towns/:id(.:format) towns#show
PUT /towns/:id(.:format) towns#update
DELETE /towns/:id(.:format) towns#destroy
내가 원하는 건 http://127.0.0.1:3000/towns/1/attractions
로 이동하지만 1
이 town.id
로 대체되는 경우 링크입니다.
감사합니다. 너무 간단합니다. – ale