나는 두 개의 개별 모델 인 Articles 및 Coffeeshops에 태그를 추가하기 위해 acts_as_taggable gem을 사용하고 있습니다. 필자는 두 모델의 태그를 완벽하게 구분하여 제출하고 표시 할 수 있습니다. 태그를 클릭하면 해당 태그가 포함 된 기사 목록이 표시됩니다. 내가 해결할 수없는 것은 Coffeeshops에서이 일을하는 방법입니다. 경로는 기사 색인으로 이동합니다. 나는 내가 가진 내가 루트에서 coffeeshop/index.html.erb
acts_as_taggable gem을 사용하여 두 테이블의 태그 경로 경로
에 routes.rb
뭔가 또한 각각의 경로를 변경해야합니다 확신 :
get 'tags/:tag', to: 'articles#index', as: :tag
이 작동하지 않습니다 분명히 커피 숍이 복제. 나는의 라인을 따라 생각하고 있어요 :
get 'tags/:article_tag, to 'articles#index, as: article_tag
get 'tags/:coffeeshop_tag, to 'coffeeshops#index, as: coffeeshop_tag
get 'articles/tags/:article_tag, to 'articles#index, as: article_tag
get 'coffeeshops/tags/:coffeeshop_tag, to 'coffeeshops#index, as: coffeeshop_tag
중 하나
하지만 어떻게 내가보기에이 변경합니까 작동하지 않는 이유는 무엇입니까? 나는 현재이 있습니다 만 undefined method 'tag_path' for #<Article:0x007fd49ab18f98> Did you mean? image_path
오류가 발생했습니다 것을
<%= raw(@article.tag_list.map { |t| link_to t, @article.tag_path(t) }.join(', ')) %>
하지만 : <%= raw(@article.tag_list.map { |t| link_to t, tag_path(t) }.join(', ')) %>
내가이 변경되었습니다.