You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: posts_controller.rb
    path of file: ./repos/coursemology2/app/controllers/course/forum
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
class Course::Forum::PostsController < Course::Forum::Co
    
  def toggle_answer
    authorize!(:toggle_answer, @topic)
    if @post.toggle_answer
      render json: { isTopicResolved: @topic.reload.resolved? }
    else
      render json: { errors: @post.errors.full_messages.to_sentence }, status: :bad_request
    end