makes tag_cloud to accept taggable

fixes links in proposals' tag cloud
This commit is contained in:
Juanjo Bazán
2015-09-13 14:38:33 +02:00
parent 890c7d55e1
commit 7cf6f0ad15
4 changed files with 17 additions and 3 deletions

View File

@@ -0,0 +1,14 @@
module TagsHelper
def taggable_path(taggable, tag_name)
case taggable
when 'debate'
debates_path(tag: tag_name)
when 'proposal'
proposals_path(tag: tag_name)
else
'#'
end
end
end

View File

@@ -51,7 +51,7 @@
<div class="small-12 medium-3 column">
<aside class="sidebar" role="complementary">
<%= link_to t("debates.index.start_debate"), new_debate_path, class: 'button radius expand' %>
<%= render "shared/tag_cloud" %>
<%= render "shared/tag_cloud", taggable: 'debate' %>
</aside>
</div>
</div>

View File

@@ -51,7 +51,7 @@
<div class="small-12 medium-3 column">
<aside class="sidebar" role="complementary">
<%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: 'button radius expand' %>
<%= render "shared/tag_cloud" %>
<%= render "shared/tag_cloud", taggable: 'proposal' %>
</aside>
</div>
</div>

View File

@@ -3,6 +3,6 @@
<h3><%= t("shared.tags_cloud.tags") %></h3>
<br>
<% tag_cloud @tag_cloud, %w[s m l] do |tag, css_class| %>
<%= link_to sanitize("#{tag.name} <span class='label round info'>#{tag.taggings_count}</span>"), debates_path(tag: tag.name), class: css_class %>
<%= link_to sanitize("#{tag.name} <span class='label round info'>#{tag.taggings_count}</span>"), taggable_path(taggable, tag.name), class: css_class %>
<% end %>
</div>