Class: RailsDb::SqlController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RailsDb::SqlController
- Defined in:
- app/controllers/rails_db/sql_controller.rb
Instance Method Summary collapse
- #csv ⇒ Object
- #execute ⇒ Object
- #import ⇒ Object
- #import_start ⇒ Object
- #index ⇒ Object
- #xls ⇒ Object
Instance Method Details
#csv ⇒ Object
16 17 18 |
# File 'app/controllers/rails_db/sql_controller.rb', line 16 def csv send_data(@sql_query.to_csv, type: 'text/csv; charset=utf-8; header=present', filename: 'results.csv') end |
#execute ⇒ Object
12 13 14 |
# File 'app/controllers/rails_db/sql_controller.rb', line 12 def execute render :index end |
#import ⇒ Object
24 25 |
# File 'app/controllers/rails_db/sql_controller.rb', line 24 def import end |
#import_start ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/rails_db/sql_controller.rb', line 27 def import_start @importer = SqlImport.new(params[:file]) result = @importer.import if result.ok? flash[:notice] = 'File was successfully imported' else flash[:alert] = "Error occurred during import: #{result.error.message}" end render :import end |
#index ⇒ Object
9 10 |
# File 'app/controllers/rails_db/sql_controller.rb', line 9 def index end |
#xls ⇒ Object
20 21 22 |
# File 'app/controllers/rails_db/sql_controller.rb', line 20 def xls render xlsx: 'xls', filename: 'results.xlsx' end |