Sha256: f8cfdddf68c6372a3628da5b4f0ddc6f188dc3c7749d14cf42774117320341ec

Contents?: true

Size: 651 Bytes

Versions: 2

Compression:

Stored size: 651 Bytes

Contents

require_dependency "telegram_chatbot/application_controller"

module TelegramChatbot
  class TelegramBotsController < ApplicationController
    before_action :set_bot, on: [:show, :upsert]

    def show
    end

    def upsert
      if @telegram_bot.update(bot_params)
        redirect_to telegram_bots_url
      else
        render :show
      end
    end

    def help
    end

    private
      def set_bot
        @telegram_bot = TelegramChatbot::TelegramBot.first || TelegramChatbot::TelegramBot.new
      end

      def bot_params
        params.require(:telegram_bot).permit(
          :token, :username, :enabled
        )
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
telegram_chatbot-0.1.3 app/controllers/telegram_chatbot/telegram_bots_controller.rb
telegram_chatbot-0.1.1 app/controllers/telegram_chatbot/telegram_bots_controller.rb