Remove helper that returned a polymorphic path

This is similar to what we did in commits 1a902a967 and fa3781059.
This commit is contained in:
Javi Martín
2024-10-23 01:25:08 +02:00
parent f5793013c9
commit 34c8559065
4 changed files with 3 additions and 14 deletions

View File

@@ -19,7 +19,7 @@
<% recommended.each do |recommended| %> <% recommended.each do |recommended| %>
<div class="small-12 medium-6 large-4 column end"> <div class="small-12 medium-6 large-4 column end">
<div class="recommendation" data-equalizer-watch> <div class="recommendation" data-equalizer-watch>
<h3><%= link_to recommended.title, recommended_path(recommended) %></h3> <h3><%= link_to recommended.title, polymorphic_path(recommended) %></h3>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@@ -1,6 +1,6 @@
class Shared::RecommendedIndexComponent < ApplicationComponent class Shared::RecommendedIndexComponent < ApplicationComponent
attr_reader :recommended, :disable_recommendations_path, :namespace attr_reader :recommended, :disable_recommendations_path, :namespace
use_helpers :recommended_path, :current_path_with_query_params use_helpers :current_path_with_query_params
def initialize(recommended, disable_recommendations_path:, namespace:) def initialize(recommended, disable_recommendations_path:, namespace:)
@recommended = recommended @recommended = recommended

View File

@@ -7,17 +7,6 @@ module WelcomeHelper
"display: none;" if index.positive? "display: none;" if index.positive?
end end
def recommended_path(recommended)
case recommended.class.name
when "Debate"
debate_path(recommended)
when "Proposal"
proposal_path(recommended)
else
"#"
end
end
def render_recommendation_image(recommended) def render_recommendation_image(recommended)
image_path = calculate_image_path(recommended) image_path = calculate_image_path(recommended)
image_tag(image_path) if image_path.present? image_tag(image_path) if image_path.present?

View File

@@ -13,7 +13,7 @@
<div class="card"> <div class="card">
<%= render_recommendation_image(recommended) %> <%= render_recommendation_image(recommended) %>
<div class="card-section"> <div class="card-section">
<%= link_to recommended_path(recommended) do %> <%= link_to polymorphic_path(recommended) do %>
<h4 class="truncate-horizontal-text"><%= recommended.title %></h4> <h4 class="truncate-horizontal-text"><%= recommended.title %></h4>
<% end %> <% end %>
<%= wysiwyg(recommended.description) %> <%= wysiwyg(recommended.description) %>