Files
once-campfire/app/controllers/accounts/bots_controller.rb
Kevin McConnell df76a227dc Hello world
First open source release of Campfire 🎉
2025-08-21 09:31:59 +01:00

40 lines
699 B
Ruby

class Accounts::BotsController < ApplicationController
before_action :ensure_can_administer
before_action :set_bot, only: %i[ edit update destroy ]
def index
@bots = User.active_bots.ordered
end
def new
@bot = User.active_bots.new
end
def create
User.create_bot! bot_params
redirect_to account_bots_url
end
def edit
end
def update
@bot.update_bot! bot_params
redirect_to account_bots_url
end
def destroy
@bot.deactivate
redirect_to account_bots_url
end
private
def set_bot
@bot = User.active_bots.find(params[:id])
end
def bot_params
params.require(:user).permit(:name, :avatar, :webhook_url)
end
end