Sha256: 98412464990569e4ae91babd929a3e7716c3d69c22d384c6a98ba42345d3362c

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

module TelegramChatbot
  module ApplicationHelper
    def form_check_toggle(option = {})
      disabled = option[:disabled].present? ? "disabled" : ""
      checked = option[:checked].present? ? "checked" : ""

      str = "<div class='form-check'>"
      str += "<label class='form-check-label form-check-toggle'>"
      str += "<input type='hidden' name='#{option[:name]}' value='0'/>"
      str += "<input type='checkbox' name='#{option[:name]}' #{checked} #{disabled}/>"
      str += "<span>#{option[:label]}</span>"
      str += "</label>"
      str + "</div>"
    end

    def method_missing(method, *args, &block)
      if (method.to_s.end_with?('_path') || method.to_s.end_with?('_url')) && main_app.respond_to?(method)
        main_app.send(method, *args)
      else
        super
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
telegram_chatbot-0.1.3 app/helpers/telegram_chatbot/application_helper.rb
telegram_chatbot-0.1.1 app/helpers/telegram_chatbot/application_helper.rb