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: competitions_controller.rb
    path of file: ./repos/ml_competition_platform/app/controllers
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class CompetitionsController < ApplicationController
  before_action :only_admin!, except: [:index, :show]

  def index
    @display_archive = params[:display_archive]
    if @display_archive
      @competitions = Competition.all.order(created_at: :desc)
    else
      @competitions = Competition.active.order(created_at: :desc)
    end
  end

  def show
 
    
  def new; end

  def create
    competition = Competition.new(competitions_params)
    competition.save!

    redirect_to root_url, notice: 'Successfully competition created'
  rescue ActiveRecord::RecordInvalid => e
    logger.error(e)
    @error_messages = ['Failed. ' + e.message]
    render :new
  end

  def edit
    @competition = Competition.find(params[:id])
  end

  def update
    @competition = Competition.find(params[:id])
    if @competition.update(competitions_params)
      redirect_to root_url, notice: 'Successfully competition updated'
    else
      @error_messages = @competition.errors.full_messages
      render :edit
    end
  end