Skip to content

Business intelligence made simple

Added fork button to edit query

Andrew Kane4e8582dffbd1
diff --git a/app/controllers/blazer/queries_controller.rb b/app/controllers/blazer/queries_controller.rb
index 713d21eb..61b69456 100644
--- a/app/controllers/blazer/queries_controller.rb
+++ b/app/controllers/blazer/queries_controller.rb
@@ -150,6 +150,10 @@ module Blazer
end
def update
+ if params[:commit] == "Fork"
+ @query = Blazer::Query.new
+ @query.creator = blazer_user if @query.respond_to?(:creator)
+ end
if @query.update(query_params)
redirect_to query_path(@query, variable_params)
else
diff --git a/app/views/blazer/queries/_form.html.erb b/app/views/blazer/queries/_form.html.erb
index 81d39e48..9091076d 100644
--- a/app/views/blazer/queries/_form.html.erb
+++ b/app/views/blazer/queries/_form.html.erb
@@ -44,6 +44,7 @@
<div class="text-right">
<% if @query.persisted? %>
<%= link_to "Delete", query_path(@query), method: :delete, "data-confirm" => "Are you sure?", class: "btn btn-danger" %>
+ <%= f.submit "Fork", class: "btn btn-info" %>
<% end %>
<%= f.submit @query.persisted? ? "Update" : "Create", class: "btn btn-success" %>
</div>