app/controllers/settings_controller.rb
##
# attempt to upgrade `user` to admin unless they already are one.
attempt to upgrade `user` to admin unless they already are one.
attempt to upgrade ` user ` to admin unless they already are one .
def attempt_admin_upgrade
    if @user.admin?
      message = I18n.t('settings.admin_users.new.already_admin', username: @user.username)
      yield json: { message: message }, status: 422
    end
    @user.update_attributes permissions: User::Permissions::ADMIN
    message = I18n.t('settings.admin_users.new.elevate_success', username: @user.username)
    yield json: { message: message }, status: 200
  end
def attempt_admin_upgrade if @user . admin? message = I18n . t ( 'settings.admin_users.new.already_admin' , username : @user . username ) yield json : { message : message } , status : 422 end @user . update_attributes permissions : User :: Permissions :: ADMIN message = I18n . t ( 'settings.admin_users.new.elevate_success' , username : @user . username ) yield json : { message : message } , status : 200 end
attempt to upgrade `user` to admin unless they already are one.
attempt to upgrade ` user ` to admin unless they already are one .
# if user was already an admin or super admin # happy path!