Class: AdminData::TableStructureController

Inherits:
ApplicationController show all
Defined in:
app/controllers/admin_data/table_structure_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#klass

Instance Method Summary collapse

Instance Method Details

#indexObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/admin_data/table_structure_controller.rb', line 6

def index
  @page_title = 'table_structure'
  @indexes = []
  if (indexes = ActiveRecord::Base.connection.indexes(@klass.table_name)).any?
    add_index_statements = indexes.map do |index|
      statment_parts = [ ('add_index ' + index.table.inspect) ]
      statment_parts << index.columns.inspect
      statment_parts << (':name => ' + index.name.inspect)
      statment_parts << ':unique => true' if index.unique

      '  ' + statment_parts.join(', ')
    end
    add_index_statements.sort.each { |index| @indexes << index }
  end
  respond_to {|format| format.html}
end