Class: MyForum::ForumsController
Instance Method Summary
collapse
#authenticate_user!, #current_user, #current_user_groups, #current_user_id, #forum_time, #is_admin?, #new_pm_count
Instance Method Details
#mark_all_as_read ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/my_forum/forums_controller.rb', line 19
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
|
#show ⇒ Object
7
8
9
10
|
# File 'app/controllers/my_forum/forums_controller.rb', line 7
def show
check_access_permissions(@forum)
@forum_topics = @forum.topics_with_latest_post_info(page: params[:page], per_page: Post::PER_PAGE)
end
|
#unread_topics ⇒ Object
12
13
14
15
16
17
|
# File 'app/controllers/my_forum/forums_controller.rb', line 12
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
|