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: roles_controller.rb
    path of file: ./repos/SalorHospitality/salor-hospitality/app/controllers
    
    the code of the file until where you have to start completion: # coding: UTF-8

# Copyright (c) 2012 Red (E) Tools Ltd.
#
# Permission is hereby gran
    
  def update
    @role = get_model
    redirect_to roles_path and return unless @role
    permitted = params.require(:role).permit :name,
        :weight,
        :permissions => []
    if @role.update_attributes permitted
      @current_company.users.where(:role_id => @role.id).update_all :role_weight => @role.weight
      flash[:notice] = t('roles.create.success')
      redirect_to roles_path
    else
      render :action => 'new'
    end