From 2a0910ca115fae7c2f561ae32e3b352d8ad8d9d1 Mon Sep 17 00:00:00 2001 From: Toks Date: Thu, 21 Nov 2013 21:07:45 -0500 Subject: [PATCH] Use ajax form for artist commentary This prevents the parameters (eg. ?tags=whatever) from being eaten on submit. --- app/controllers/artist_commentaries_controller.rb | 2 +- app/views/artist_commentaries/_form.html.erb | 2 +- app/views/artist_commentaries/create_or_update.js.erb | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 app/views/artist_commentaries/create_or_update.js.erb diff --git a/app/controllers/artist_commentaries_controller.rb b/app/controllers/artist_commentaries_controller.rb index 59fb1feff..579def6f1 100644 --- a/app/controllers/artist_commentaries_controller.rb +++ b/app/controllers/artist_commentaries_controller.rb @@ -11,7 +11,7 @@ class ArtistCommentariesController < ApplicationController @artist_commentary = ArtistCommentary.create(params[:artist_commentary]) end - respond_with(@artist_commentary.post) + respond_with(@artist_commentary) end def revert diff --git a/app/views/artist_commentaries/_form.html.erb b/app/views/artist_commentaries/_form.html.erb index dc3ee1f47..de623cf18 100644 --- a/app/views/artist_commentaries/_form.html.erb +++ b/app/views/artist_commentaries/_form.html.erb @@ -1,6 +1,6 @@

If the artist of this image posted some interesting additional information about this work, you can copy it here.

-<%= form_tag(create_or_update_artist_commentaries_path, :class => "simple_form", :method => :put) do %> +<%= form_tag(create_or_update_artist_commentaries_path(:format => :js), :remote => true, :class => "simple_form", :method => :put) do %>
<%= hidden_field :artist_commentary, :post_id, :value => @post.id %> diff --git a/app/views/artist_commentaries/create_or_update.js.erb b/app/views/artist_commentaries/create_or_update.js.erb new file mode 100644 index 000000000..345366b9b --- /dev/null +++ b/app/views/artist_commentaries/create_or_update.js.erb @@ -0,0 +1 @@ +location.reload();