Business intelligence made simple
Use js-routes
Andrew Kane72be4b8f5590
diff --git a/app/assets/javascripts/blazer/application.js b/app/assets/javascripts/blazer/application.jsindex 928fbef8..648837f4 100644--- a/app/assets/javascripts/blazer/application.js+++ b/app/assets/javascripts/blazer/application.js@@ -57,7 +57,7 @@ function csrfProtect(payload) {}function remoteCancelQuery(runningQuery) {- var path = window.cancelQueriesPath;+ var path = Routes.blazer_cancel_queries_path();var data = {run_id: runningQuery.run_id, data_source: runningQuery.data_source};if (navigator.sendBeacon) {navigator.sendBeacon(path, csrfProtect(data));@@ -103,7 +103,7 @@ function runQuery(data, success, error, runningQuery) {function runQueryHelper(data, success, error, runningQuery) {var xhr = $.ajax({- url: window.runQueriesPath,+ url: Routes.blazer_run_queries_path(),method: "POST",data: data,dataType: "html"@@ -320,7 +320,7 @@ function showEditor() {preventBackspaceNav();function updatePreviewSelect() {- var dataSource = $("#query_data_source").val();- $("#tables").load(tablesPath + "?" + $.param({data_source: dataSource}));- $("#view-schema").attr("href", schemaPath + "?data_source=" + dataSource);+ var dataSource = $("#query_data_source").val()+ $("#tables").load(Routes.blazer_tables_queries_path({data_source: dataSource}))+ $("#view-schema").attr("href", Routes.blazer_schema_queries_path({data_source: dataSource}))}diff --git a/app/views/layouts/blazer/application.html.erb b/app/views/layouts/blazer/application.html.erbindex 66c882c5..36cfbdd8 100644--- a/app/views/layouts/blazer/application.html.erb+++ b/app/views/layouts/blazer/application.html.erb@@ -8,12 +8,6 @@<%= stylesheet_link_tag "blazer/application" %><%= javascript_include_tag "blazer/application" %><%= Gon::Base.render_data %>- <script>- var runQueriesPath = <%= run_queries_path.to_json.html_safe %>;- var cancelQueriesPath = <%= cancel_queries_path.to_json.html_safe %>;- var schemaPath = <%= schema_queries_path.to_json.html_safe %>;- var tablesPath = <%= tables_queries_path.to_json.html_safe %>;- </script><% if blazer_maps? %><%= stylesheet_link_tag "https://api.mapbox.com/mapbox.js/v2.4.0/mapbox.css" %><%= javascript_include_tag "https://api.mapbox.com/mapbox.js/v2.4.0/mapbox.js" %>