Note that there are some explanatory texts on larger screens.

plurals
  1. POArchitecture for image tagging
    text
    copied!<p>I am not getting further since days with the best structure to choose for my purpose. I have:</p> <pre><code>class Image &lt; ActiveRecord::Base attr_accessible :date, :description, :name, :image, :tag_ids has_many :taggings, :dependent =&gt; :destroy has_many :tags, :through =&gt; :taggings mount_uploader :image, ImageUploader end </code></pre> <p>Then:</p> <pre><code>class Tag &lt; ActiveRecord::Base attr_accessible :name has_many :taggings, :dependent =&gt; :destroy has_many :images, :through =&gt; :taggings end </code></pre> <p>And:</p> <pre><code>class Tagging &lt; ActiveRecord::Base belongs_to :image belongs_to :tag attr_accessible :image_id, :tag_id end </code></pre> <p>I have three main categories for now, all images belong into 'Solar System', 'Milky Way' or 'Universe'. Let's say I have an image of Saturn, so I tag it 'Saturn' and 'Solar System'. An image of a moon of saturn will further be tagged with 'Moon'. An image of Andromeda Galaxy will be tagged 'Universe' and 'Galaxy'.</p> <p>If I want to display all images e.g. of the Solar System with the url: www.website.com/solarsystem</p> <p>There shall be links to e.g. Jupiter or Saturn. If I click Saturn the url shall be: www.website.com/solarsystem/saturn ...and it shall display all images tagged with 'Saturn'.</p> <p>The category structure (which will also be displayed) as a link shall in this case be:</p> <p>Home > Solar System > Saturn</p> <p>All categories are clickable and lead you to the images of the category. With the Image, Tag and Tagging model I find it very difficult to achieve all this. E.g. in /image/show.html I have problems to display the correct links of the category structure since they depend on the tag of the image. E.g. I need to say if tag.name = 'Saturn' then the 1st link shall be "Solar System". If tag.name = 'Galaxy', then the 1st link shall be "Universe". But with many tags and combinations it gets quite confusiong. Also the correct url (www.website.com/solarsystem/saturn) is not easy for me to achieve.</p> <p>Is there a good solution, maybe with another model structure, maybe having an own model for all tags like 'Saturn' or 'Jupiter'?</p>
 

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