Sha256: 5461137b533c3d90dc3280bd60b164a05f78760f0e129cc7fc52547f3aa41ff6

Contents?: true

Size: 993 Bytes

Versions: 1

Compression:

Stored size: 993 Bytes

Contents

module RedisMonitor
  module Helpers
    module DatabaseHelper
      def current_database
        session[:database].to_i
      end

      def databases
        Backend.databases.each do |database|
          database_option(database)
        end
      end

      def database_option(database)
        haml_tag :option, {selected: (database.to_i == current_database.to_i)} do
          haml_concat database
        end
      end

      def choose_database_select
        capture_haml do
          haml_tag :form, action: '/content/change_database', method: 'post' do
            haml_tag :div, class: 'form-group' do
              haml_tag :label, for: 'database_select' do
                haml_concat 'Select database'
              end

              haml_tag :select, id: 'database_select', name: 'database', class: 'selectpicker form-control', data: {style: 'btn-info'} do
                databases
              end
            end
          end

        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis_monitor-0.1 lib/helpers/database_helper.rb