<%= form_for query, html: {class: 'form query-form', role: 'form'} do |f| %>
<%= f.text_area :query, class: 'form-control', rows: 15, required: true %>
<% if query.persisted? %> <%= link_to query do %> Cancel <% end %> <% else %> <%= link_to :queries do %> Back to Index <% end %> <% end %>
<%= link_to '#nameAndDesc', class: 'btn btn-default btn-sm', data: {toggle: 'modal', target: '#nameAndDesc'} do %> Save as... <% end %>
<% end %>

Query preview <%= link_to preview_path, class: 'js-preview-button', data: {source: '#query_query', result: '.js-preview-result', remote: true, method: 'POST'} do %> Refresh <% end %>

Preview is shown here

Query explain <%= link_to explain_path, class: 'js-explain-button', data: {source: '#query_query', result: '.js-explain-result', remote: true, method: 'POST'} do %> Refresh <% end %>

Explain result is shown here