Move recommended index partial to a component
Thanks to it, we can slightly simplify the debates view rendering it.
This commit is contained in:
14
app/components/shared/recommended_index_component.rb
Normal file
14
app/components/shared/recommended_index_component.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class Shared::RecommendedIndexComponent < ApplicationComponent
|
||||
attr_reader :recommended, :disable_recommendations_path, :namespace
|
||||
use_helpers :recommended_path, :current_path_with_query_params
|
||||
|
||||
def initialize(recommended, disable_recommendations_path:, namespace:)
|
||||
@recommended = recommended
|
||||
@disable_recommendations_path = disable_recommendations_path
|
||||
@namespace = namespace
|
||||
end
|
||||
|
||||
def render?
|
||||
feature?("user.recommendations") && recommended.present?
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user