Class: Dbviewer::EntityRelationshipDiagramsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/dbviewer/entity_relationship_diagrams_controller.rb

Instance Method Summary collapse

Methods included from ErrorHandling

#handle_database_error, #log_error

Methods included from DatabaseOperations

#calculate_schema_size, #current_table?, #database_manager, #execute_query, #export_table_to_csv, #fetch_database_analytics, #fetch_table_columns, #fetch_table_metadata, #fetch_table_record_count, #fetch_table_records, #fetch_table_relationships, #fetch_tables_with_stats, #get_database_name, #prepare_query, #safe_quote_table_name

Instance Method Details

#indexObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/dbviewer/entity_relationship_diagrams_controller.rb', line 3

def index
  @tables = fetch_tables_with_stats

  if @tables.present?
    @table_relationships = fetch_table_relationships
  else
    @table_relationships = []
    flash.now[:warning] = "No tables found in database to generate ERD."
  end

  respond_to do |format|
    format.html # Default to HTML view
    format.json do
      render json: {
        tables: @tables,
        relationships: @table_relationships
      }
    end
  end
end