Sha256: 0bce6140b629aa7ba31e1400e3ff037bec9945b513376aecbae75c760e97d6b1

Contents?: true

Size: 1.04 KB

Versions: 62

Compression:

Stored size: 1.04 KB

Contents

require_dependency "my_forum/application_controller"

module MyForum
  class ForumsController < ApplicationController
    before_filter :find_forum, only: [:show]

    def show
      check_access_permissions(@forum)
      @forum_topics = @forum.topics_with_latest_post_info(page: params[:page], per_page: Post::PER_PAGE)
    end

    def unread_topics
      redirect_to root_path and return unless current_user
      @forum_topics = Forum.unread_topics_with_latest_post_info(user_id: current_user_id, page: params[:page], per_page: 30)

      render action: :show
    end

    def mark_all_as_read
      redirect_to root_path and return unless current_user

      Topic.find_in_batches(batch_size: 500) do |topic_group|
        topic_group.each do |topic|
          log = LogReadMark.find_or_create_by(user_id: current_user.id, topic_id: topic.id)
          log.post_id = topic.latest_post_id
          log.save
        end
      end

      redirect_to root_path
    end

    private

    def find_forum
      @forum = Forum.find(params[:id])
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
my_forum-0.0.2.4 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.2.3 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.2.2 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.2.1 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.2 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta60 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta59 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta58 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta57 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta56 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta55 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta54 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta53 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta52 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta51 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta50 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta49 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta48 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta47 app/controllers/my_forum/forums_controller.rb
my_forum-0.0.1.beta46 app/controllers/my_forum/forums_controller.rb