내가 방법을 배우고 싶은
[comment.article, comment]
그것을 사용하려면,이게 무슨 의미. 저는 이해가 안되며 어떤 문서도 찾을 수 없습니다.
<%= link_to 'Destroy Comment', [comment.article, comment],
method: :delete,
data: { confirm: 'Are you sure?' } %>
대신 article_comment_path (주석 포함 작동되지
<%= link_to 'Destroy Comment', article_comment_path,
method: :delete,
data: { confirm: 'Are you sure?' } %>
() 오류가 표시 :
여기ActiveRecord::RecordNotFound in CommentsController#destroy
<%= link_to 'Destroy Comment', article_comment_path(comment)
루트
Prefix Verb URI Pattern Controller#Action
article_comments GET /articles/:article_id/comments(.:format) comments#index
POST /articles/:article_id/comments(.:format) comments#create
new_article_comment GET /articles/:article_id/comments/new(.:format) comments#new
edit_article_comment GET /articles/:article_id/comments/:id/edit(.:format) comments#edit
article_comment GET /articles/:article_id/comments/:id(.:format) comments#show
PATCH /articles/:article_id/comments/:id(.:format) comments#update
PUT /articles/:article_id/comments/:id(.:format) comments#update
DELETE /articles/:article_id/comments/:id(.:format) comments#destroy
articles GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article GET /articles/new(.:format) articles#new
edit_article GET /articles/:id/edit(.:format) articles#edit
article GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#update
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy
root GET / articles#index
article_comment_path (comment)를 사용하면 오류가 발생합니다. CommentsController # destroy ActiveRecord :: RecordNotFound –
내 질문은 가이드의 [comment.article, comment]의 의미입니다. –
나는 같은 질문을했고 당신의 질문을 보았습니다. 그러나 나는 그것을 알아 냈다. [comment.article, comment]는 중첩 된 경로가있는 링크가있을 때 사용할 수있는 Rails의 약자입니다. 그래서 그냥 편의. 중첩 된 경로를 사용하려면 부모 레코드의 id (comment.article과 함께있는 article id)와 자식 레코드 (comment id)가 필요합니다. 더 명시 적으로하려면 경로를 포함하고 괄호 안에 매개 변수를 대괄호로 묶지 마십시오 (예 : article_comment_path (comment.article, comment)). 그리고 실제로 위의 대답에서 경로를 사용하십시오. –