Class: Course::Video::TopicsController

Inherits:
Controller show all
Includes:
Discussion::PostsConcern
Defined in:
app/controllers/course/video/topics_controller.rb

Instance Method Summary collapse

Methods included from Discussion::PostsConcern

#skip_update_topic_status, #update_topic_pending_status

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


14
15
16
17
18
19
20
21
22
# File 'app/controllers/course/video/topics_controller.rb', line 14

def create
  result = @topic.class.transaction do
    raise ActiveRecord::Rollback unless @post.save && create_topic_subscription && update_topic_pending_status
    raise ActiveRecord::Rollback unless @topic.save
    true
  end

  head :bad_request unless result
end

#indexObject


8
9
10
11
12
# File 'app/controllers/course/video/topics_controller.rb', line 8

def index
  @topics = @video.topics.includes(posts: :children).order(:timestamp)
  @topics = @topics.reject { |topic| topic.posts.empty? }
  @posts = @topics.map(&:posts).inject(Course::Discussion::Post.none, :+)
end

#showObject


24
25
# File 'app/controllers/course/video/topics_controller.rb', line 24

def show
end