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: sections_controller.rb
    path of file: ./repos/coursemology2/app/controllers/course/survey
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
class Course::Survey::SectionsController < Course::Survey::Controller
  load_and_authorize_
    
  def create
    last_weight = @survey.sections.maximum(:weight)
    @section.weight = last_weight ? last_weight + 1 : 0
    if @section.save
      render_section_json
    else
      render json: { errors: @section.errors }, status: :bad_request
    end