Files
nairobi/app/components/relationable/related_list_component.rb
Javi Martín c8d8fae98d Move related list partial to a component
This way the code is easier to follow; the code checking whether the
list has contents is in the partial rendering the list.

We also remove some duplication setting up related content in the
controllers.

For some reason, we have to manually ignore i18n keys which were
automatically ignored when the code was in the view.
2021-08-16 16:30:13 +02:00

19 lines
415 B
Ruby

class Relationable::RelatedListComponent < ApplicationComponent
attr_reader :relationable
delegate :current_user, to: :helpers
def initialize(relationable)
@relationable = relationable
end
def render?
related_contents.present?
end
private
def related_contents
@related_contents ||= Kaminari.paginate_array(relationable.relationed_contents).page(params[:page]).per(5)
end
end