From 7cf6f0ad15e3231ab2c87d4cf40e230452bc7757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Sun, 13 Sep 2015 14:38:33 +0200 Subject: [PATCH] makes tag_cloud to accept taggable fixes links in proposals' tag cloud --- app/helpers/tags_helper.rb | 14 ++++++++++++++ app/views/debates/index.html.erb | 2 +- app/views/proposals/index.html.erb | 2 +- app/views/shared/_tag_cloud.html.erb | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 app/helpers/tags_helper.rb diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb new file mode 100644 index 000000000..b8476ac0a --- /dev/null +++ b/app/helpers/tags_helper.rb @@ -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 diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb index b910a0c0c..256fe3755 100644 --- a/app/views/debates/index.html.erb +++ b/app/views/debates/index.html.erb @@ -51,7 +51,7 @@
diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index 788e1ce95..df6dd2352 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -51,7 +51,7 @@
diff --git a/app/views/shared/_tag_cloud.html.erb b/app/views/shared/_tag_cloud.html.erb index 737fc3a94..171b85b3c 100644 --- a/app/views/shared/_tag_cloud.html.erb +++ b/app/views/shared/_tag_cloud.html.erb @@ -3,6 +3,6 @@

<%= t("shared.tags_cloud.tags") %>


<% tag_cloud @tag_cloud, %w[s m l] do |tag, css_class| %> - <%= link_to sanitize("#{tag.name} #{tag.taggings_count}"), debates_path(tag: tag.name), class: css_class %> + <%= link_to sanitize("#{tag.name} #{tag.taggings_count}"), taggable_path(taggable, tag.name), class: css_class %> <% end %>