Преглед на файлове

Revert "Set tables in controller"

This reverts commit 13385191312b6619254257c65d3488ca7d810482.
Andrew Kane преди 10 години
родител
ревизия
cb6fe61c6a
променени са 2 файла, в които са добавени 2 реда и са изтрити 6 реда
  1. 1 5
      app/controllers/blazer/queries_controller.rb
  2. 1 1
      app/views/blazer/queries/_form.html.erb

+ 1 - 5
app/controllers/blazer/queries_controller.rb

@@ -13,7 +13,6 @@ module Blazer
 
     before_action :ensure_database_url
     before_action :set_query, only: [:show, :edit, :update, :destroy]
-    before_action :set_tables, only: [:new, :edit]
 
     def index
       @queries = Blazer::Query.order(:name).includes(:creator)
@@ -136,10 +135,6 @@ module Blazer
       @query = Blazer::Query.find(params[:id].to_s.split("-").first)
     end
 
-    def set_tables
-      @tables = tables
-    end
-
     def query_params
       params.require(:query).permit(:name, :description, :statement)
     end
@@ -218,6 +213,7 @@ module Blazer
       rows, error = run_statement(Blazer::Connection.send(:sanitize_sql_array, ["SELECT table_name, column_name, ordinal_position, data_type FROM information_schema.columns WHERE table_schema = ?", schema]))
       Hash[ rows.group_by{|r| r["table_name"] }.map{|t, f| [t, f.sort_by{|f| f["ordinal_position"] }.map{|f| f.slice("column_name", "data_type") }] }.sort_by{|t, f| t } ]
     end
+    helper_method :tables
 
   end
 end

+ 1 - 1
app/views/blazer/queries/_form.html.erb

@@ -16,7 +16,7 @@
           <%= link_to "Back", :back %>
           <span class="text-muted" style="margin-left: 20px;"> Use {start_time} and {end_time} for time ranges</span>
         </div>
-        <%= select_tag :table_names, options_for_select([["Preview table", nil]] + @tables.keys), style: "margin-right: 20px; width: 240px;" %>
+        <%= select_tag :table_names, options_for_select([["Preview table", nil]] + tables.keys), style: "margin-right: 20px; width: 240px;" %>
         <%= link_to "Run", "#", class: "btn btn-info", id: "run", style: "vertical-align: top;" %>
       </div>
     </div>