From be69e5911b8bffda2658261a3b06fc26e8d1ff9f Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Fri, 11 Jun 2021 16:44:06 +0200 Subject: [PATCH] suite --- app/controllers/forum/forum_topics_controller.rb | 5 +++++ app/views/forum/forum_topics/index.haml | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/app/controllers/forum/forum_topics_controller.rb b/app/controllers/forum/forum_topics_controller.rb index efb5299..2ef85b5 100644 --- a/app/controllers/forum/forum_topics_controller.rb +++ b/app/controllers/forum/forum_topics_controller.rb @@ -24,6 +24,11 @@ class Forum::ForumTopicsController < ApplicationController def index @forum_topics = ForumTopic.where(:enabled => true).all + + per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 40 + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @forum_topics = @forum_topics.page(page).per(per_page) + end def show diff --git a/app/views/forum/forum_topics/index.haml b/app/views/forum/forum_topics/index.haml index cc7036c..e3f3d09 100644 --- a/app/views/forum/forum_topics/index.haml +++ b/app/views/forum/forum_topics/index.haml @@ -12,6 +12,10 @@ -if moderator? %th{:style => "width:50px;"} =render @forum_topics + + + #pagination + = paginate @forum_topics, :remote => false =link_to "Lancer un fil de discussion", new_forum_forum_topic_path, :class => "btn btn-primary", :style => "margin:1em 0em;float:right" \ No newline at end of file