Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding related tags using acts-as-taggable-on
    primarykey
    data
    text
    <p>In tag#show I list all entries with that tag. At the bottom of the page I'd like to have something like: "Related Tags: linked, list, of, related tags" My view looks like:</p> <pre><code>&lt;h2&gt;&lt;%= link_to 'Tag', tags_path %&gt;: &lt;%= @tag.name.titleize %&gt;&lt;/h2&gt; &lt;% @entries.each do |entry| %&gt; &lt;h2&gt;&lt;%= link_to h(entry.name), entry %&gt;&lt;/h2&gt; &lt;%- unless entry.phone.empty? -%&gt; &lt;p&gt;&lt;%= h(entry.phone) %&gt;&lt;/p&gt; &lt;%- end -%&gt; &lt;%- unless entry.address.empty? -%&gt; &lt;p&gt;&lt;%= h(entry.address) %&gt;&lt;/p&gt; &lt;%- end -%&gt; &lt;%- unless entry.description.empty? -%&gt; &lt;p&gt;&lt;%= h(entry.description) %&gt;&lt;/p&gt; &lt;%- end -%&gt; &lt;p2&gt;&lt;%= link_to "more...", entry %&gt;&lt;p2&gt; &lt;% end %&gt; Related Tags: &lt;% @related.each do |tag| %&gt; &lt;%= link_to h(tag.tags), tag %&gt; &lt;% end %&gt; </code></pre> <p>tags_controller.rb:</p> <pre><code>def show @title = Tag.find(params[:id]).name @tag = Tag.find(params[:id]) @entries = Entry.paginate(Entry.find_tagged_with(@tag), :page =&gt; params[:page], :per_page =&gt; 10, :order =&gt; "name") @related = Entry.tagged_with(@tag, :on =&gt; :tags) end </code></pre> <p>Every entry has at least one tag, it's required by the entry model. I'd like duplicate tags ignored and the current tag (the tag that the list belongs to) ignored. My current code displays this:</p> <p>Related Tags: Gardens Gardens ToursGardens</p> <p>Gardens is a link to the entry, not the tag gardens. ToursGardens is a link to the entry that includes those tags.</p> <p>My desired result would be:</p> <p>Related Tags: Gardens, Tours</p> <p>Each link would link to it's associated tag. Can anyone help me achieve this? I tried using a div_for but I don't think that was right.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload