sequel - Sorting tags by .post.count in rails -
i've been developing blog in rails , i'm having issues small feature. able sort tags on page number of posts have attached them. used tagging system 1 found @ jumpstart tutorial. maybe not way should have gone. i'm not sure how write sequel in controller order it. or if tagging method wouldn't way go.
the relationship such
#tag.rb has_many :taggings has_many :posts, through: :taggings #post.rb has_many :taggings has_many :tags, through: :taggings #tagging.rb belongs_to :tag belongs_to :post i can call in count enough once have specify tag selected.
tag = tag.first tag.posts.count #outputs post count on tag thank time
my problem logic. trying count posts tag when should have been trying count taggings. good post here on how set cache counter in rails
Comments
Post a Comment