diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index be3bd56..1c619c8 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -82,6 +82,13 @@ def update end end + def disable + @question = Question.find(params[:id]) + @question.disable = true + @question.save! + head :ok + end + # /questions/admin def admin @questions = Question.all_ready_to_go diff --git a/public/javascripts/application.js b/public/javascripts/application.js index c96d8c7..8969be1 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -16,6 +16,6 @@ $(document).ready(function(){ var parent_tr = $(this).parents("tr")[0]; $(parent_tr).slideUp(); var id = $(parent_tr).attr("id"); - // AJAX the update POST + $.post("/questions/"+id+"/disable", { _method: "put", authenticity_token: encodeURIComponent(window._auth_token)}); }); }); \ No newline at end of file