Class: TelegramBotEngine::Admin::AllowlistController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/telegram_bot_engine/admin/allowlist_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
# File 'app/controllers/telegram_bot_engine/admin/allowlist_controller.rb', line 14

def create
  AllowedUser.create!(allowed_user_params)
  redirect_to admin_allowlist_index_path, notice: "Username added to allowlist."
rescue ActiveRecord::RecordInvalid => e
  redirect_to admin_allowlist_index_path, alert: e.message
end

#destroyObject



21
22
23
24
25
# File 'app/controllers/telegram_bot_engine/admin/allowlist_controller.rb', line 21

def destroy
  allowed_user = AllowedUser.find(params[:id])
  allowed_user.destroy!
  redirect_to admin_allowlist_index_path, notice: "Username removed from allowlist."
end

#indexObject



8
9
10
11
12
# File 'app/controllers/telegram_bot_engine/admin/allowlist_controller.rb', line 8

def index
  @bots = Bot.order(:name)
  @allowed_users = AllowedUser.includes(:bot).order(:username)
  @allowed_users = @allowed_users.where(bot_id: params[:bot_id]) if params[:bot_id].present?
end