私はacts_as_taggable gemを使用して、2つの別々のモデルの記事とCoffeeshopsにタグを追加しています。私は2つのモデルのタグを別々に提出し、完全に表示する能力を持っています。タグをクリックすると、そのタグだけを含む記事のリストも表示されます。私がうまくいかないのは、Coffeeshopsのためにこれを行う方法です。パスは記事のインデックスに移動します。私は私が持っている路線ではroutes.rb
で何かを変更する必要があるともcoffeeshop/index.html.erb
acts_as_taggable gemを使用して2つのテーブルのタグのルートパス
内の個々のパスます確信しています:
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
:私はの線に沿って考えていますか?私は現在持っている: <%= raw(@article.tag_list.map { |t| link_to t, tag_path(t) }.join(', ')) %>
私はこれを変更:
<%= raw(@article.tag_list.map { |t| link_to t, @article.tag_path(t) }.join(', ')) %>
だけundefined method 'tag_path' for #<Article:0x007fd49ab18f98> Did you mean? image_path
エラーを投げたこと。