Merge pull request #1361 from consul/taggable_path

adds taggables/s path helper
This commit is contained in:
Raimond Garcia
2017-01-18 18:50:30 +01:00
committed by GitHub
3 changed files with 18 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
module TagsHelper
def taggable_path(taggable_type, tag_name)
def taggables_path(taggable_type, tag_name)
case taggable_type
when 'debate'
debates_path(search: tag_name)
@@ -13,4 +13,18 @@ module TagsHelper
end
end
def taggable_path(taggable)
taggable_type = taggable.class.name.underscore
case taggable_type
when 'debate'
debate_path(taggable)
when 'proposal'
proposal_path(taggable)
when 'budget/investment'
budget_investment_path(taggable.budget_id, taggable)
else
'#'
end
end
end

View File

@@ -5,7 +5,7 @@
<ul class="no-bullet tag-cloud">
<% @tag_cloud.tags.each do |tag| %>
<li class="inline-block">
<%= link_to taggable_path(taggable, tag.name) do %>
<%= link_to taggables_path(taggable, tag.name) do %>
<span class="tag"><%= tag.name %></span>
<% end %>
</li>

View File

@@ -5,14 +5,14 @@
<% taggable.tag_list_with_limit(limit).each do |tag| %>
<li class="inline-block">
<%= link_to sanitize(tag.name),
taggable_path(taggable.class.name.underscore, tag.name),
taggables_path(taggable.class.name.underscore, tag.name),
search: tag.name %></li>
<% end %>
<% if taggable.tags_count_out_of_limit(limit) > 0 %>
<li class="inline-block">
<%= link_to "#{taggable.tags_count_out_of_limit(limit)}+",
send("#{taggable.class.name.underscore}_path", taggable) %>
taggable_path(taggable) %>
</li>
<% end %>
</ul>