Module: DatabaseHelper

Defined in:
lib/engine/app/helpers/database_helper.rb

Instance Method Summary collapse

Instance Method Details

#choose_database_select(dbs) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/engine/app/helpers/database_helper.rb', line 14

def choose_database_select(dbs)
  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(dbs)
        end
      end
    end

  end
end

#database_option(database) ⇒ Object



8
9
10
11
12
# File 'lib/engine/app/helpers/database_helper.rb', line 8

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

#databases(dbs) ⇒ Object



2
3
4
5
6
# File 'lib/engine/app/helpers/database_helper.rb', line 2

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