Use polymorphic_path instead of taggables_path
We forgot to make this change when we started using "resolve" to generate polymorphic nested resources. The taggables_path method can be replaced with the polymorphic_path of a class. It even works with nested resources, given the current page already has the nested resources params (in this case, `budget_id` for investments).
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
module TagsHelper
|
||||
def taggables_path(taggable_type, tag_name)
|
||||
case taggable_type
|
||||
when "debate"
|
||||
debates_path(search: tag_name)
|
||||
when "proposal"
|
||||
proposals_path(search: tag_name)
|
||||
when "budget/investment"
|
||||
budget_investments_path(@budget, search: tag_name)
|
||||
when "legislation/proposal"
|
||||
legislation_process_proposals_path(@process, search: tag_name)
|
||||
else
|
||||
"#"
|
||||
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)
|
||||
when "legislation/proposal"
|
||||
legislation_process_proposal_path(@process, taggable)
|
||||
else
|
||||
"#"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -26,7 +26,7 @@
|
||||
<% if @map_location&.available? %>
|
||||
<%= render "budgets/investments/map" %>
|
||||
<% end %>
|
||||
<%= render "shared/tag_cloud", taggable: "budget/investment" %>
|
||||
<%= render "shared/tag_cloud", taggable: "Budget::Investment" %>
|
||||
<%= render "budgets/investments/categories" %>
|
||||
|
||||
<% if @heading && can?(:show, @ballot) %>
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
|
||||
<aside class="margin-bottom">
|
||||
<%= link_to t("debates.index.start_debate"), new_debate_path, class: "button expanded" %>
|
||||
<%= render "shared/tag_cloud", taggable: "debate" %>
|
||||
<%= render "shared/tag_cloud", taggable: "Debate" %>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
|
||||
<% if params[:retired].blank? %>
|
||||
<%= render "categories" %>
|
||||
<%= render "shared/tag_cloud", taggable: "proposal" %>
|
||||
<%= render "shared/tag_cloud", taggable: "Proposal" %>
|
||||
<%= render "geozones" %>
|
||||
<% end %>
|
||||
<%= render "retired" %>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<div class="small-12 medium-3 column">
|
||||
<aside class="sidebar">
|
||||
<%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: "button radius expand" %>
|
||||
<%= render "shared/tag_cloud", taggable: "proposal" %>
|
||||
<%= render "shared/tag_cloud", taggable: "Proposal" %>
|
||||
<%= render "categories" %>
|
||||
<%= render "geozones" %>
|
||||
</aside>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<aside class="sidebar">
|
||||
<%= link_to t("map.start_proposal"),
|
||||
new_proposal_path, class: "button radius expand" %>
|
||||
<%= render "shared/tag_cloud", taggable: "proposal" %>
|
||||
<%= render "shared/tag_cloud", taggable: "Proposal" %>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<ul class="no-bullet tag-cloud">
|
||||
<% @tag_cloud.tags.each do |tag| %>
|
||||
<li class="inline-block">
|
||||
<%= link_to taggables_path(taggable, tag.name) do %>
|
||||
<%= link_to polymorphic_path(taggable.constantize, search: tag.name) do %>
|
||||
<span class="tag"><%= tag.name %></span>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
<% taggable.tag_list_with_limit(limit).each do |tag| %>
|
||||
<li class="inline-block">
|
||||
<%= link_to sanitize(tag.name),
|
||||
taggables_path(taggable.class.name.underscore, tag.name) %></li>
|
||||
polymorphic_path(taggable.class, 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)}+",
|
||||
taggable_path(taggable) %>
|
||||
polymorphic_path(taggable) %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user