Class: Course::Forum::TopicsController

Inherits:
ComponentController show all
Includes:
TopicControllerHidingConcern, TopicControllerLockingConcern, TopicControllerSubscriptionConcern
Defined in:
app/controllers/course/forum/topics_controller.rb

Instance Method Summary collapse

Methods included from TopicControllerSubscriptionConcern

#subscribe

Methods included from TopicControllerLockingConcern

#set_locked

Methods included from TopicControllerHidingConcern

#set_hidden

Methods included from ApplicationSignInCallbacksConcern

#sign_in

Methods included from ApplicationPaginationConcern

#page_param

Methods included from ApplicationAnnouncementsConcern

#global_announcements, #unread_global_announcements

Methods included from ApplicationInstanceUserConcern

#current_instance_user

Methods included from ApplicationUserTimeZoneConcern

#set_time_zone

Methods included from ApplicationUserConcern

#handle_access_denied, #publicly_accessible?

Methods included from ApplicationComponentsConcern

#handle_component_not_found

Instance Method Details

#createObject


22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/course/forum/topics_controller.rb', line 22

def create
  authorize_topic_type!(@topic.topic_type)

  if @topic.save
    send_created_notification(@topic)
    redirect_to course_forum_topic_path(current_course, @forum, @topic),
                success: t('.success', title: @topic.title)
  else
    render 'new'
  end
end

#destroyObject


49
50
51
52
53
54
55
56
57
# File 'app/controllers/course/forum/topics_controller.rb', line 49

def destroy
  if @topic.destroy
    redirect_to course_forum_path(current_course, @forum),
                success: t('.success', title: @topic.title)
  else
    redirect_to course_forum_topic_path(current_course, @forum, @topic),
                danger: t('.failure', error: @topic.errors.full_messages.to_sentence)
  end
end

#editObject


34
35
# File 'app/controllers/course/forum/topics_controller.rb', line 34

def edit
end

#newObject


19
20
# File 'app/controllers/course/forum/topics_controller.rb', line 19

def new
end

#showObject


13
14
15
16
17
# File 'app/controllers/course/forum/topics_controller.rb', line 13

def show
  @topic.viewed_by(current_user)
  @topic.mark_as_read!(for: current_user)
  @reply_post = @topic.posts.build
end

#updateObject


37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/course/forum/topics_controller.rb', line 37

def update
  @topic.assign_attributes(update_topic_params)
  authorize_topic_type!(@topic.topic_type)

  if @topic.save
    redirect_to course_forum_topic_path(current_course, @forum, @topic),
                success: t('.success', title: @topic.title)
  else
    render 'edit'
  end
end